Thursday, July 21, 2011

Android - SimpleOnGestureListener not receiving event

If you are creating SimpleOnGestureListener to capture double tab, single tab, etc... event and your extended class is not responding or capturing any event, the below information may help

Overriding onDown method

Make sure you override onDown(MotionEvent e) and return true

@Override
public boolean onDown(MotionEvent e) {
return true;
}

By default, SimpleOnGestureListener onDown method return false. However, every touch event start at onDown. If this onDown method return false, the event will not propagate to other event method such as onDoubleTab and onSingleTabConfirmed. Therefore, those event method will not be trigger.

2 comments:

  1. That saved my time, was googleing for an hour why the doubleTab wasn't working for me.

    ReplyDelete