Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2.3k
AdapterViewEvents
Since AndroidAnnotations 1.0
You can bind methods to handle events on items in an AdapterView:
- Item clicks with
@ItemClick - Long item clicks with
@ItemLongClick - Item selection with
@ItemSelect
The annotation value should be one or several of R.id.* fields. If not set, the method name will be used as the R.id.* field name.
Methods annotated with @ItemClick or @ItemLongClick must have one parameter. This parameter can be of any type, it's the object retrieved when calling adapter.getItem(position).
Methods annotated with @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)
publicclassMyListActivityextendsActivity {
// ...@ItemClickpublicvoidmyListItemClicked(MyItemclickedItem) {
}
@ItemLongClickpublicvoidmyListItemLongClicked(MyItemclickedItem) {
}
@ItemSelectpublicvoidmyListItemSelected(booleanselected, MyItemselectedItem) {
}
}Since AndroidAnnotations 2.4
For
@ItemClick,@ItemLongClickand@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)
publicclassMyListActivityextendsActivity {
// ...@ItemClickpublicvoidmyListItemClicked(intposition) {
}
@ItemLongClickpublicvoidmyListItemLongClicked(intposition) {
}
@ItemSelectpublicvoidmyListItemSelected(booleanselected, intposition) {
}
}19/11/2020 The 4.8.0 release is out !
- Get started!
- Cookbook, full of recipes
- Customize annotation processing
- List of all available annotations
- Release Notes
- Examples
- Read the FAQ
- Join the Mailing list
- Create an issue
- Tag on Stack Overflow
- Ask on Gitter