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