Android: Event handling method for gesture swipe

Source: Internet
Author: User

First the activity must implement the Ongesturelistener interface, which provides some methods for gesture manipulation,
Ondown method: Ondown is, once the touch screen is pressed, the Ondown event is generated immediately
public boolean Ondown (Motionevent e) {
return false;
}
Onfling method: Triggers when the hand is sliding on the screen but the hand does not leave the screen
Motionevent Motionevent Object Where the E1 hand begins to touch the position of the screen
Motionevent E2 The Motionevent object where the hand ends the touch screen
Float Velocityx indicates the movement speed of the hand in the horizontal direction
Float Velocityx indicates the movement speed of the hand in the vertical direction
public boolean onfling (Motionevent E1, motionevent E2, float Velocityx, float velocityy)

Onlongpress method: Triggers when the screen is long pressed
public void Onlongpress (Motionevent e)

Onscroll method: Triggers when the hand slides off the screen, with the same parameters as onfling (note the difference between the two)
public boolean onscroll (Motionevent E1, motionevent E2, float Distancex, float distancey)

Onshowpress method: Click on the touch screen, but there is no movement and bounce action onshowpress and Ondown difference is that Ondown is, once the touch screen is pressed, immediately generate Ondown events, But Onshowpress is the Ondown event, a period of time, if not move the mouse and bounce events, it is considered to be the Onshowpress event.
public void Onshowpress (Motionevent e)

Onsingletapup method: After tapping the touch screen, pop up. If the onlongpress, Onscroll, and onfling events are produced in this process, no Onsingletapup events will be generated.
public boolean onsingletapup (Motionevent e)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.