http://blog.csdn.net/iamfafa/article/details/6316062
There are two classes in Android
Android.view.GestureDetector
Android.view.GestureDetector.SimpleOnGestureListener
(another android.widget.Gallery seems to be the ongesturelistener of the Bull X)
1) Create a new class to inherit Simpleongesturelistener,hahagesturedetectorlistener
The following event events can be implemented.
Boolean Ondoubletap (Motionevent e)
Explanation: triggered when double click on second touch down
Boolean ondoubletapevent (Motionevent e)
Explanation: The second touch down and up of double-click are triggered and can be distinguished by e.getaction ().
Boolean Ondown (Motionevent e)
Explanation: Triggered when Touch is down
Boolean onfling (Motionevent E1, motionevent E2, float Velocityx, float velocityy)
Explanation: Touch is triggered after sliding a little distance up.
void Onlongpress (Motionevent e)
Explanation: Touch does not move until touch down is triggered
Boolean onscroll (Motionevent E1, motionevent E2, float Distancex, float distancey)
Explanation: Touch triggered when sliding.
void Onshowpress (Motionevent e)
Explanation: Touch has not yet slid when triggered
(Compare with Ondown,onlongpress
Ondown as long as touch down must be triggered immediately.
and touchdown after a while not sliding first triggered onshowpress and then onlongpress.
So after touchdown has not slipped, ondown->onshowpress->onlongpress this sequence trigger.
)
Boolean onsingletapconfirmed (Motionevent e)
Boolean onsingletapup (Motionevent e)
Explanation: Both of these functions are not sliding after touch down (onscroll), not long pressed (onlongpress), and then triggered when touchup.
Click on the very fast (do not swipe) Touchup:
Ondown->onsingletapup->onsingletapconfirmed
Click on a slightly slower (not sliding) Touchup:
Ondown->onshowpress->onsingletapup->onsingletapconfirmed
2) Create a new Gesturedetector object in the view.
In the constructor gesturedetector = new Gesturedetector (new Hahagesturedetectorlistener ());
And then in the ontouchevent of the view, the following, you can write your own code in the event that was just 1.
@Override
public boolean ontouchevent (Motionevent event) {
Gesturedetector.ontouchevent (event);
}
However, the depressed is Simpleongesturelistener did not provide onup (), but also in the view of the
Ontouchevent's
Case MOTIONEVENT.ACTION_UP:
To write the corresponding code.
Android Screen Swipe Event