当前位置:首页 > 未命名 > 正文内容

Android View Event dispatch

u3blog8年前 (2016-03-10)未命名205

There are three mainly methods in event dispatch

public boolean dispatchTochEvent(MotionEvent ev) dispatch event the return value mean if consume this event public boolean onInterceptTouchEvent(MotionEvent event) show if this view intercept this event, if true, this method not invoke again. public boolean onTouchEvent(MotionEvent event) use to handle event, if return false, this view not receive this series of event again. below code show the relationship of these three method
public boolean onTouchEvent(MotionEvent ev){
      boolean consume = false;
      if(onInterceptTouchEvent(ev)){
           consume = onTouchEvent(ev);
            }else{
                consume = child.dispatchTouchEvent(ev);
                }
               returen consume;
            }
In the end of this link is onTouchEvent, in side, if we have set onClickListener, it will be invoke, onClickListener is the last priority.

The order of events dispatch

When click event generate the dispatch order is ACTIVITY->WINDOW->View In this order, event will arrived to bottom view, if this view can't handle, the event will give to parent view, and so on.

扫描二维码推送至手机访问。

版权声明:本文由u3blog发布,如需转载请注明出处。

本文链接:https://u3blog.xyz/?id=272

分享给朋友:

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。