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

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

How to use

The method should be this way:

  • public void onClick()
  • public void onClick(View v)

Example

@OnClick(R.id.button)
public void onClick() {
    Toast.makeText(this, "Button clicked", Toast.LENGTH_SHORT).show();
}