First, write a class that inherits Simpleongesturelistener, and rewrite the corresponding function as needed. Here is the function of the corresponding function
1, press (Ondown): Just finger touch to the screen of the moment, is the touch of that moment.
2, throw (onfling): Finger on the touch screen to move sequentially, and loosen the action.
3, Long Press (onlongpress): The finger on the touch screen for a period of time, and did not loosen.
4. Scroll (onscroll): Swipe your finger on the touchscreen.
5, Hold (onshowpress): Finger on the touch screen, his time range in the press, before the long press.
6, lift Up (onsingletapup): The finger left the touch screen of that instant.
Note: Any gesture action will first perform a pressed action
Press and hold action before long press
Hold action and press action to perform a lift
No lifting action after long press, scrolling, and throwing
Second, define a Gesturedetector variable in the activity where you want to add the gesture, and when you add a listener to the variable, initialize the variable,
Gesturedetector = Newgesturedetector (listener).
Thirdly, the dispatchtouchevent function of the function activity must be overloaded in the activity.