forked from androidannotations/androidannotations
-
Notifications
You must be signed in to change notification settings - Fork 0
AdapterViewEvents
pyricau edited this page May 10, 2012
·
2 revisions
Since AndroidAnnotations 1.0
You can bind methods to handle events on items in an AdapterView:
-
Item clicks with
@ItemClick -
Long item clicks with
@LongItemClick -
Item selection with
@ItemSelect
@ItemClick and @LongItemClick may have one parameter. This parameter can be of any type, it's the object retrieved when calling adapter.getItem(position).
@ItemSelect may 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.
@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,@LongItemClickand@ItemSelect, if the parameter is of typeint, then the position is given instead of the object coming from the adapter.
@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) {
}
}14/06/2012 The 2.6 release is out
- Get started!
- Cookbook, full of recipes
- List of all available annotations
- Release Notes
- Examples
- Read the FAQ
- Join the Mailing list
- Create an issue
- Tag on Stack Overflow