Android: Event handling method for gesture swipe

Source: Internet
Author: User

Ext.: http://www.2cto.com/kf/201307/229485.html

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, immediately generate Ondown event public boolean ondown (Motionevent e) {return false;} Onfling method: When the hand is sliding on the screen but the hand does not leave the screen, the Motionevent object that triggers the Motionevent E1 hand starts to touch the position of the screen motionevent the E2 object where the hand ends the touch screen float Velocityx represents the movement speed of the hand in the horizontal direction float Velocityx represents the movement speed of the hand in the vertical direction public boolean onfling (Motionevent E1, motionevent E2, float Velocityx, float Velocityy) Onlongpress method: triggers the public void onlongpress (Motionevent e) Onscroll method when the screen is long pressed: triggers when the hand slides off the screen Parameters are the same 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: Bounces after tapping the touchscreen. If the onlongpress, Onscroll, and onfling events are produced in this process, no Onsingletapup events will be generated. public boolean onsingletapup (Motionevent e)

Android: Event handling method for gesture swipe

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.