This repository was archived by the owner on Jun 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Event Listener Binding
Steven Lewi edited this page Jul 13, 2015
·
5 revisions
You can tag any method in your class as an event listener using annotation. Some of the annotations require the method to have mandatory parameters. This is the list of supported event.
@OnClick(R.id.btn1)
public void button1Clicked() {
}@OnLongClick(R.id.btn1)
public void button1LongClicked() {
}@OnFocusChange(R.id.edit_text1)
public void editText1FocusChanged(boolean hasFocus) {
// Method that tagged using @OnFocusChange needs to have 1 boolean parameter.
}@OnTouch(R.id.view1)
public void onViewTouched(MotionEvent event) {
// Method that tagged using @OnTouch needs to have 1 MotionEvent parameter.
}@OnItemClick(R.id.list_view1)
public void listViewItemClicked(int position) {
// Method that tagged using @OnItemClick needs to have 1 int parameter.
}@OnItemLongClick(R.id.list_view1)
public void listViewItemLongClicked(int position) {
// Method that tagged using @OnItemLongClick needs to have 1 int parameter.
}@OnItemSelected(R.id.spinner1)
public void spinner1ItemSelected(int position) {
// Method that tagged using @OnItemSelected needs to have 1 int parameter.
}@OnCheckedChanged(R.id.checkbox1)
public void checkBox1CheckedChanged(boolean checked) {
// Method that tagged using @OnCheckedChanged needs to have 1 boolean parameter.
}