Android: How to Handle gesture slide events

Source: Internet
Author: User

First, the Activity must implement the OnGestureListener interface, which provides some methods for gesture operations. The onDown method: onDown is, once the touch screen is pressed, the onDown event public boolean onDown (MotionEvent e) {return false;} onFling method will be generated immediately: the MotionEvent object MotionEvent e2 that triggers MotionEvent e1 when the hand slides on the screen but the hand does not leave the screen. The MotionEvent object float velocityX indicates that the hand is the horizontal movement speed float velocityX indicates the vertical movement speed of the hand. public boolean onFling (MotionEvent e1, motionEvent e2, float velocityX, float velocityY) onLon GPress method: trigger public void onLongPress (MotionEvent e) onScroll when you press the screen. Method: the parameter is the same as that of onFling when your hand slides away from the screen) public boolean onScroll (MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) onShowPress method: Click the touch screen, but there is no moving or popping action onShowPress and onDown, the difference is that onDown is, once the touch screen is pressed, The onDown event is generated immediately. However, after the onShowPress event is generated, if the mouse is not moved or the event is popped up for a period of time, it is considered an onShowPress event. Public void onShowPress (MotionEvent e) onSingleTapUp Method: After a touch screen is tapped, it pops up. If onLongPress, onScroll, and onFling events are generated in this process, the onSingleTapUp event will not 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.