A simple understanding of touch event delivery

Source: Internet
Author: User

The understanding of the view event delivery, see this article.
Has a general understanding of event delivery. The Onintercepttouchevent function determines whether the event is intercepted, and after interception, all child controls of the control cannot receive this event. The Ontouchevent function determines whether to consume this event, and if the parent control passes the event to the child control without interception, the message is passed to the underlying control, the underlying control can choose to consume or not to consume, and if it consumes, then the event terminates, and if there is no consumption, one layer is passed to the parent class. If it is intercepted halfway, the intercepted control acts as the underlying control for the above procedure. Most importantly, in this process, the control that the event passes through executes the Ontouchevent method, except that the return value is different to determine consumption or not, for example, the parent control ontouchevent The return value is true, the child control is false, and the parent control is not intercepted. The end of the event is the parent control, but the Ontouchevent method of the child control is executed! It's just not spending. In the touch process, only the ACTION_DOWM event consumes, in order to consume move and up events, understand, do not press, how to move and lift.
Before the study of the refresh control, encountered the problem: when the pull area width is greater than the critical value, then release the finger to start the refresh, if I want to cancel, then only the finger to slide upward, so that the width is less than the critical width and then let go, but, the actual situation is, then the finger slide upward, The ListView also starts to slide, and the drop-down area is outside the screen. The right thing to do is to prevent the listview from sliding and then cancel the ban, and then the solution is to determine the situation in the ListView ontouchevent () and directly return true to resolve. At that time, the understanding was superficial, just to return to true to consume the event, it was done. Now it's not the case at all, so look at that code again. A simple analysis of the drop-down refresh control
Try to output the super.ontouchevent (EV) in the ListView, and find that this value is true, it feels wrong, and I think it is different, since all are returned true, why the above solution. So it is assumed that super.ontouchevent (EV) is not simply returning a true so simple that it may also respond to and change the scrollbar of the ListView, Open Abslistview.java, look at this method, sure enough, there are a lot of code, so it can be explained, directly return true, so that the default Ontouchevent method is not executed in Abslistview, so the scroll bar does not scroll.
The ListView is equivalent to the parent control, item is a child control, and the other controls in the item layout are double controls, which can be implemented by controlling touch event delivery according to functional requirements.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

A simple understanding of touch event delivery

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.