API Demo GestureBuilderActivity分析一
来源:互联网 发布:易顺佳服装鞋业软件 编辑:程序博客网 时间:2024/05/18 13:31
在看API Demo中的GestureBuilderActivity时候遇到了一个比较恶心的问题:
本来想看Add gesture这个Button的点击事件是如何写的,但是根据他的id没有能找到
<Button android:id="@+id/addButton" android:onClick="addGesture" android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" android:enabled="false" android:text="@string/button_add" />但是根据代码中函数的名字和断点调试发现走的就是下面的函数:
@SuppressWarnings({"UnusedDeclaration"}) public void addGesture(View v) { Intent intent = new Intent(this, CreateGestureActivity.class); startActivityForResult(intent, REQUEST_NEW_GESTURE); }仔细一看原来定义这个Button的时候有一个属性android:onClick="addGesture"
However, instead of applying an OnClickListener
to the button in your activity, you can assign a method to your button in the XML layout, using the android:onClick
attribute. For example:
<Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="@string/self_destruct" android:onClick="selfDestruct" />
Now, when a user clicks the button, the Android system calls the activity's selfDestruct(View)
method. In order for this to work, the method must be public and accept a View
as its only parameter. For example:
public void selfDestruct(View view) { // Kabloey }
The View
passed into the method is a reference to the widget that was clicked.
- API Demo GestureBuilderActivity分析一
- API Demo SearchableDictionary代码分析一
- API Demo Snake代码分析一 FrameLayout新的认识
- API DEMO LabelView分析
- Api-Demo Advanced preference分析
- android api demo 每日一例:api demo 概要
- Openstack Api分析(一)
- API Demo SearchableDictionary代码分析二
- API Demo Snake代码分析二 onSaveInstanceState和onRestoreInstanceState分析
- API Demo Snake代码分析三 程序架构的分析
- Android Api demo系列(一) (App>Activity>Animation)
- Gin源码分析(一)官方demo分析
- 【Android API】Android动画源码分析(一)
- 【RxJava Demo分析】(一)just、error、defer和CompositeSubscription
- demo-rgbd论文解析+代码分析(一)
- Replugin Demo的简单使用与分析(一)
- lehpone api demo学习
- API DEMO APPWIGHT 学习
- Cocoa的MVC架构分析
- SQLITE3 使用总结
- S3C2440 SDRAM驱动配置编程
- LOCAL_MODULE_TAGS 选项说明
- iOS UIResponder 学习笔记
- API Demo GestureBuilderActivity分析一
- Oracle中使用关键字作为字段名的方法
- 项目笔记
- 硅谷新生代 编码成瘾不惧失败
- Android开发札记 1
- Intent.ACTION
- 继承概念与方法的重写小结
- HDU 4016 Magic Bitwise And Operation
- 最具颠覆性的10大科技思想者