Skip to content
dexafree edited this page Aug 21, 2014 · 4 revisions

This annotation will trigger an event when a TextView receives an action such as pressing ENTER key or a custom action on the keyboard.

How to use

The method should be this way:

  • public boolean onEditorAction(KeyEvent event)
  • public boolean onEditorAction(TextView textView, KeyEvent event)

Example

@OnEditorAction(R.id.edit_text)
public boolean onEditorAction(KeyEvent event) {
    Toast.makeText(this, "Editor action received", Toast.LENGTH_SHORT).show();
    return false;
}

More information