多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > php開源 > 綜合技術 > DispatchTouchEvent & OnInterceptTouchEvent & onTouchEvent的含義和區別

DispatchTouchEvent & OnInterceptTouchEvent & onTouchEvent的含義和區別

來源:程序員人生   發布時間:2015-03-25 11:52:06 閱讀次數:3968次
1.DispatchTouchEvent

     Pass the touch screen motion event down to the target view, or this view if it is the target.
     傳遞觸摸事件到目標視圖,或他就是目標視圖。


情況1:return true

則事件只會在當前方法內消耗掉,且不會向下傳遞,最后傳給Activity.
情況2:return false  

則事件只會在當前方法內消耗不會向下傳遞,最后傳給Activity。
但是不同于情況1,呈U型傳遞的進程不會傳到當前的布局

情況3:super.dispatchTouchEvent(MotionEvent)

 全部進程會經歷當前ViewGroup的3個觸摸事件,dispatchTouch -> interceptTouch -> onTouchEvent。



2.OnInterceptTouchEvent

     Implement this method to intercept all touch screen motion events. This allows you to watch events as they are dispatched to your children, and take ownership of the current gesture at any point.
     實現這個方法是為了監測所有的屏幕觸摸事件。這個允許你視察 事件分發給你的子視圖,并且具有當前任何點的手勢的權限。
 
     Using this function takes some care, as it has a fairly complicated interaction with View.onTouchEvent(MotionEvent), and using it requires implementing that method as well as this one in the correct way. Events will be received in the 
  following order:
     使用這個方法需要注點意, 由于它和OnTouchEvent有著非常復雜的交互,在使用它的時候1樣需要實現這個方法并且正確使用。事件將會依照以下順序接收:
     
  1. You will receive the down event here.
    按下的事件會在這里接收。

  2. The down event will be handled either by a child of this view group, or given to your own onTouchEvent() method to handle; this means you should implement onTouchEvent() to return true, so you will continue to see the rest of the gesture (instead of looking for a parent view to handle it). Also, by returning true from onTouchEvent(), you will not receive any following events in onInterceptTouchEvent() and all touch processing must happen in onTouchEvent() like normal.
    按下事件將會被這視圖里面的子視圖處理,否則就被分發onTouchEvent 方法去處理 ; 這就意味著你應當實現 onTouchEvent 返回true, 所以你將會繼續看到剩下的手勢。而且,通過從onTouchEvent方法返回true,你不會在onInterceptTouchEvent方法中接收任何事件并且所有的觸摸處理1定會在onTouchEvent中正常產生。

  3. For as long as you return false from this function, each following event (up to and including the final up) will be delivered first here and then to the target's onTouchEvent().
    只要你從這個函數返回false,每一個緊隨著的事件將會 傳遞到這里然后分發到目標的的OnTouchEvent().

  4. If you return true from here, you will not receive any following events: the target view will receive the same event but with the action MotionEvent.ACTION_CANCEL, and all further events will be delivered to your onTouchEvent() method and no longer appear here.
    如果你返回true,你就不會接收到以下事件:目標視圖將接收到一樣的事件而且只有MotionEvent.Action_Cancel,而且所有未來的事件將會傳遞到你的onTouchEvent 方法,并且不在會出現在這里。

情況1:return true
事件傳遞將依照dispatch-> intercept-> onTouch進行傳遞,終究返回到Activity。
情況2:return false
正常傳遞
情況3: super.onInterceptTouchEvent(ev);

正常傳遞






3.OnTouchEvent

     Implement this method to handle touch screen motion events.
     不管觸摸事件是不是被處理,true || false 事件都會向下進行傳遞。
生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 国产精欧美一区二区三区 | 最近中文免费字幕在线播放 | 中文字幕精品在线 | 伊人网久久网 | 亚洲精品久久久久中文字幕一区 | 欧美色视频网 | 亚洲 欧美 日韩 综合aⅴ视频 | 性欧美极品videos | 国产精品亚洲欧美一级久久精品 | 满18看的毛片 | 精品福利一区二区免费视频 | 亚洲图片激情小说 | 免费观看性欧美毛片 | a毛片久久免费观看 | 在线亚洲精品国产成人二区 | 欧美最猛黑人xxxx黑人猛交 | 国产精品1页| 亚洲欧美日韩国产精品网 | 久久免费观看国产精品 | 亚色中文| 亚洲伊人成综合网 | 欧美性生交大片 | 性香港xxxxx免费视频播放 | 亚洲视频在线一区二区 | 亚洲春色另类 | 亚洲色图另类小说 | 亚洲欧美一区二区三区蜜芽 | 18到20女人一级毛片 | 精品视频网站 | 日本欧美小视频 | h网站在线看 | 亚洲欧美在线综合一区二区三区 | 亚洲欧美韩国日本 | 日韩久久网 | 美国毛片亚洲社区在线观看 | 亚洲一区二区三区夜色 | 亚洲图片自拍偷拍 | babes性欧美高清 | 第九色激情 | 欧美性天天| 国产成人精品.一二区 |