Link to home
Start Free TrialLog in
Avatar of GlobaLevel
GlobaLevelFlag for United States of America

asked on

Android - get gestures from user on touch screen

I need to get the values of gestures that a user registers on the touch screen so if they tap one launches this method, if they tap twice launches this method ...
Avatar of davebytes
davebytes
Flag of United States of America image

Doing this off the top of my head...

1) add GestureDetector.OnDoubleTapListener to the interfaces list for your view class
2) early in creation of your view (constructor usually), create the gesture handler, like:
mGestures = new GestureDetector(context, this);
That makes a gesture detector object (which, obviously, needs to be a member of the view class..) that will dispatch any gestures to the view as callbacks.
3) in the view's onTouchEvent handler, let the gesture handler have first shot:
mGestures.onTouchEvent(e);
.. then do any other handling.
4) Finally, implement onDoubleTap, onSingleTapConfirmed, callbacks to differentiate/handle the two events.

Hope that helps!
Avatar of GlobaLevel

ASKER

thanks so much...would you have any sample code by any chance?
ASKER CERTIFIED SOLUTION
Avatar of davebytes
davebytes
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial