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

This annotation will trigger an event when a View is touched.

How to use

The method should be this way:

  • public boolean onTouch(MotionEvent event)
  • public boolean onClick(View v, MotionEvent event)

Example

@OnTouch(R.id.button)
public boolean onTouch(MotionEvent event) {
    Toast.makeText(this, "Button touched, action: $event.action", Toast.LENGTH_SHORT).show();
    return false;
}