Android Learning Note (11) Touch Event mechanism

Source: Internet
Author: User

There are three functions for event handling in Android, Dispatchtouchevent, Onintercepttouchevent, and Ontouchevent, and these three functions return the True/false value to manage the distribution mechanism of events. In fact, three functions can be used from its function name to understand the usefulness of these functions, need to be analyzed from the whole

The first is dispatchtouchevent, the event is passed from the parent control to the child control from the outside, and the Dispatchtouchevent return value indicates whether the event is assigned to the current View,false, which represents the ontouchevent that is returned to the parent control, The down pass stops, reaching the effect of giving feedback to the parent control; Returns true to indicate that the current view is assigned, but whether it will continue to be assigned is determined by the onintercepttouchevent and ontouchevent of the current view; By default it is assigned to the current view

The second is onintercepttouchevent, such as the literal meaning, whether the view interrupts this event, true means interrupt and is handled by the view's ontouchevent, false means no interruption, The dispatchtouchevent assigned to the child view continues to decide whether to assign;

Finally, ontouchevent, how to handle the event, returns true to handle the event and consumes it, no longer passes, and false means no consumption and returns the ontouchevent of the parent view to handle this.

Android Learning Note (11) Touch Event mechanism

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.