Add basic steps for Android gestures (1)

Source: Internet
Author: User

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.

Related Article

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.