Great God quotes 1 how to slide fragmentmanager inside a fragment inside the viewgroup---dispatchtouchevent, onintercepttouchevent, ontouchevent

Source: Internet
Author: User

Question: How does the system know if the user is sliding a (the page in the black box) or B (the FGM in the red box)

Answer:

-dispatchtouchevent, Onintercepttouchevent, ontouchevent

Problem Resolution:

This can be said to be an Android event handling problem, first introduce the great God said these three events "

Each view subclass in the Android system has the following three methods that are closely related to TouchEvent processing:

1) Public boolean dispatchtouchevent (motionevent ev) This method is used to distribute TouchEvent

2) Public boolean onintercepttouchevent (motionevent ev) This method is used to intercept touchevent

3) Public boolean ontouchevent (motionevent ev) This method is used to process touchevent

When touchevent occurs, the activity first passes the touchevent to the topmost view, TouchEvent first to the dispatchtouchevent of the topmost view, and then by Dispatchtouchevent Method for distribution, if Dispatchtouchevent returns True, the ontouchevent processing of the view is given, and if Dispatchtouchevent returns False, the view's Intercepttouchevent method to decide whether or not to intercept this event, if Intercepttouchevent returns True, that is, intercept it, then give it the ontouchevent to handle, if Intercepttouchevent returns FALSE, it is passed to the child view, and the dispatchtouchevent of the sub view begins the distribution of the event. If the event is passed to the ontouchevent of a child view of a layer, this method returns false, and the event is passed from this view to the ontouchevent to receive. If the ontouchevent passed to the top also returns false, the event "disappears" and the next event is not received.

Thousand said that not better than experts say

The simple point is to judge whether the departure is on the component, to execute te, not to upload, and then judge

Hongyangblog said it's clear to everyone to see

Great God quotes 1 how to slide fragmentmanager inside a fragment inside the viewgroup---dispatchtouchevent, onintercepttouchevent, ontouchevent

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.