public boolean dispatchtouchevent (Motionevent ev) {}
For the distribution of events, all events in Android must be distributed through this method, and then decide whether to consume the current event itself or continue to distribute it to child control processing. Returns true to indicate that the distribution is not continued and the event is not consumed.
public boolean onintercepttouchevent (Motionevent arg0) {}
For the handling of the event, returns true to indicate that the consumer handles the current event, returns false without processing, and gives the child control to continue distribution.
public boolean ontouchevent (Motionevent arg0) {}
Responsible for intercepting events, returning true to intercept the current event, do not continue to distribute, to their own ontouchevent for processing. return false to Not intercept, continue to pass.
For example, the transfer relationship between three methods is illustrated by adding an interface such as:
The transitive relationship is as follows:
Example: Android viewpage Disable Sliding screen ( If other view can customize the control and then override these methods )
The Android event mechanism is transmitted from the parent view to the child view, which can be used to detect if your current sub-view has a sliding control, etc., to determine if the event is blocked, but this trouble, and does not solve all the problems (you have to detect if the touch point is on the control), there is a relatively simple way to inject the control into your nested Viewpager instance, and then in Ontouchevent,onintercepttouchevent,dispatchtouchevent inside tell the parent view, that is viewpager don't stop truncates the Touch event on the control.
requestdisallowintercepttouchevent (True); true Disables
Adding code in Child view is generally as follows:
public boolean OnTouch (View V, motionevent event) {
switch (event.getaction ()) {
case motionevent.action_move: &NBSP
requestdisallowintercepttouchevent (true);
break;
case MOTIONEVENT.ACTION_UP:
case Motionevent.action_cancel:
requestdisallowintercepttouchevent (false);
break;
}
}
when the user presses, we tell the parent component not to intercept my event (this time the subassembly is able to respond to the event normally) and then pick up and tell the parent component to to block.
Public Boolean dispatchtouchevent (Motionevent ev) {} is used to distributeTouchEvent
Event passing between Android controls