Notes KeyEvent and TouchEvent in the order in which the activity and view are passed

Source: Internet
Author: User

There are some problems with the transmission of a TV key event, but the five-bit arrow keys sometimes have problems

so using activity completely takes over the transfer of the key event, controlling the change of focus and the pressing processing logic of the five-bit direction key .

Review The key event delivery here, the log is as follows

The key event is assigned from the activity, then the view is processed first, and the last activity is processed



Touch Events




View.java only dispatchtouchevent   and Ontouchevent

VG only Dispatchtouchevent and Onintercepttouchevent one more dispatchtransformedtouchevent .  Vg.java No outouchevent, VG's ontouchevent is actually a VG inherited view, and touch processing is the same as view.


Complete Process:

1.vg.dispatchtouchevent


2.vg.onintercepttouchevent-if intercepted, then directly execute my own Ontouch (that is, super.dispatchtouchevent )


3.vg.dispatchtransformedtouchevent

if onintercepttouchevent returns not true, that is, it is not intercepted, then it is distributed to the child, and if there is no child, perform the touch of my own view

two cases are as follows:   4. Traverse all the children in this VG:

A If there are no children in this VG, call this VG's view of the dispatchtouchevent that is super.dispatchtouchevent

B Otherwise, perform the children's Ontouch.

5.super.dispatchtouchevent will eventually execute to:

Montouchlistener.ontouch

6. Ontouchevent (event)




Finally, the WMS invokes the activity's ontouchevent




Notes KeyEvent and TouchEvent in the order in which the activity and view are passed

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.