ClickEvents - PerfectCarl/androidannotations GitHub Wiki
@Click
Since AndroidAnnotations 1.0
The @Click
annotation indicates that an activity method must be called when the corresponding view is clicked.
The view id can be set in the annotation parameter, ie @Click(R.id.myButton)
.
If the view id is not set, the name of the method will be used to guess the view id.
The method may have zero or one parameter, and this parameter can only be a View (the view that was clicked). The method must not be private. Two different methods cannot handle the same view.
Usage example:
@Click(R.id.myButton)
void myButtonWasClicked() {
[...]
}
@Click
void anotherButton() {
[...]
}
@Click
void yetAnotherButton(View clickedView) {
[...]
}
Other events
AndroidAnnotations supports other kind of events, and it works exactly as with @Click
.
Currently, AndroidAnnotations supports the following events on views:
- Clicks with
@Click
- Long clicks with
@LongClick
- Touches with
@Touch