AndroidAnnotations——Listening to AdapterViewEvents监听适配器视图事件
2014-04-07 18:23
483 查看
AndroidAnnotationAdapterViewEvents
You can bind methods to handle events on items in an AdapterView:
你可以绑定方法来处理适配器视图中项目的事件:
Item clicks with
Long item clicks with
Item selection with
Methods annotated with
have one parameter. This parameter can be of any type, it's the object retrieved when calling
加了
Methods annotated with
have one or two parameters. The first parameter must be a boolean, and the second is the object from the adapter, at the selected position.
加了
Since AndroidAnnotations 2.4
For
if the parameter is of type
given instead of the object coming from the adapter.
对于
可以和 AndroidAnnotations——Adapters
and lists 适配器和列表 文档结合起来看
AdapterViewEvents适配器视图事件
Since AndroidAnnotations 1.0You can bind methods to handle events on items in an AdapterView:
你可以绑定方法来处理适配器视图中项目的事件:
Item clicks with
@ItemClick
Long item clicks with
@ItemLongClick
Item selection with
@ItemSelect
Methods annotated with
@ItemClickor
@ItemLongClickmust
have one parameter. This parameter can be of any type, it's the object retrieved when calling
adapter.getItem(position).
加了
@ItemClick和
@ItemLongClick注解的方法必须有一个参数。这个参数可以是任何类型的,调用
adapter.getItem(position)时返回一个object对象。
Methods annotated with
@ItemSelectmay
have one or two parameters. The first parameter must be a boolean, and the second is the object from the adapter, at the selected position.
加了
@ItemSelect注解的方法可能有一个或两个参数。第一个参数必须是boolean类型,第二个参数是适配器中被选位置的对象。
@EActivity(R.layout.my_list) public class MyListActivity extends Activity { // ... @ItemClick public void myListItemClicked(MyItem clickedItem) { } @ItemLongClick public void myListItemLongClicked(MyItem clickedItem) { } @ItemSelect public void myListItemSelected(boolean selected, MyItem selectedItem) { } }
Since AndroidAnnotations 2.4
For
@ItemClick,
@ItemLongClickand
@ItemSelect,
if the parameter is of type
int, then the position is
given instead of the object coming from the adapter.
对于
@ItemClick,
@ItemLongClick和
@ItemSelect来说,如果参数是
int类型的,那么适配器将传送位置值代替对象值。
@EActivity(R.layout.my_list) public class MyListActivity extends Activity { // ... @ItemClick public void myListItemClicked(int position) { } @ItemLongClick public void myListItemLongClicked(int position) { } @ItemSelect public void myListItemSelected(boolean selected, int position) { } }
可以和 AndroidAnnotations——Adapters
and lists 适配器和列表 文档结合起来看
相关文章推荐
- AndroidAnnotations——Listening to AdapterViewEvents监听适配器视图事件
- Android 解析RecyclerView(1)——带点击事件监听的通用Adapter
- Android 触摸事件监听(Activity层,ViewGroup层,View层)详细介绍
- android中ListView中在Adapter中为Button设置监听事件方法--跳转Activity
- android CursorAdapter的监听事件
- Android新浪微博开发(三)主UI的实现:用BaseAdapter做适配器的LsitView
- Android中ListView与适配器ArrayAdapter,SimpleAdapter,定义BaseAdapter适配器,ListView添加headerView,ListView滚动到最后一项
- android用Adapter实现ListView的初始化报错android.widget.LinearLayout cannot be cast to android.widget.TextView
- 适配器Adapter(视图View):HashMap中entrySet实现
- Android开发:监听当前View的左右滑动事件,并返回给当前的activity或者fragment
- Error: cannot be cast to android.widget.HeaderViewListAdapter
- Android 监听EditView中的文本改变事件
- Android ViewPager事件滑动监听修改
- Android:ViewPager适配器PagerAdapter的使用
- 一看就会Android之列表视图组件ListView结合Adapter的使用及监听
- cannot be cast to android.widget.HeaderViewListAdapter
- cannot be cast to android.widget.HeaderViewListAdapter
- android ViewPager实现无限轮播和设置监听事件
- android CursorAdapter的监听事件
- android CursorAdapter的监听事件