PerformClick () trigger condition in Android:view

Source: Internet
Author: User

First look at PerformClick () source code:

 Public Boolean PerformClick () {        sendaccessibilityevent (accessibilityevent.type_view_clicked);          if NULL ) {            playsoundeffect (soundeffectconstants.click);            Monclicklistener.onclick (this);             return true ;        }          return false ;    }

From the source can be seen, as long as the use of the View.setonclicklistener () method to set up the listener, it will automatically trigger View.performclick ().

It is important to note that if the View.setontouchlistener () method is used at the same time, there may be a response event that intercepts View.performclick () because when the view. Ontouchevent () inevent.getaction () = = Motionevent.action_down returns FALSE, the system will assume that the view does not need to process the touch event, then the subsequent touch events (move, up, click) will not be passed in , so it does not triggerView.performclick (), while View.setontouchlistener () is equivalent to rewriting the view. Ontouchevent (), so when you write the View Touchlistener processing, you need to pay attention to whether the view has click event Monitoring, if so, use View.performclick () to trigger the Click event in the appropriate location. This article transferred from: http://blog.sina.com.cn/s/blog_70ae1d7b0102v7uk.html

PerformClick () trigger condition in Android:view

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.