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

This annotation will trigger an event when a View (for example, a Button) is long-clicked.

How to use

The method should be this way:

  • public boolean onLongClick()
  • public boolean onLongClick(View v)

Notice it must return a boolean

Example

@OnLongClick(R.id.button)
public boolean onLongClick() {
    Toast.makeText(this, "Button long clicked", Toast.LENGTH_SHORT).show();
    return true;
}

More information about return