Android: Perfect solution to the Setonitemclicklistener and Setontouchlistener conflict issues in the ListView

Source: Internet
Author: User

@Overridepublic boolean OnTouch (View V, motionevent event) {Createvelocitytracker (event); switch (Event.getaction ()) { Case MotionEvent.ACTION_DOWN:xDown = Event.getrawx (); Break;case MotionEvent.ACTION_MOVE:xMove = EVENT.GETRAWX ();// The active distance int distancex = (int) (xmove-xdown);//Get Shun time speed int xspeed = getscrollvelocity ();// Returns to the previous activityif (Distancex > Xdistance_min && xspeed > Xspeed_min) When the sliding distance is greater than the minimum distance we set and the instantaneous speed of the slide is greater than the speed we set {finish ();//Set Toggle animation, enter from the right, exit//overridependingtransition on the left (R.anim.in_from_left, r.anim.out_to_right);} else {return false;} Break;case MotionEvent.ACTION_UP:recycleVelocityTracker (); break;default:break;} Return false;//returns false to respond to the Click event}
<span style= "FONT-SIZE:24PX;" ><strong> in the end, return false to respond to the Click event, perfect resolution for handling event conflict issues!!!!! </strong></span>

Android: Perfect solution to the Setonitemclicklistener and Setontouchlistener conflict issues in the ListView

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.