日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

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

DispatchTouchEvent & OnInterceptTouchEvent & onTouchEvent的含義和區別

來源:程序員人生   發布時間:2015-03-25 11:52:06 閱讀次數:3978次
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 事件都會向下進行傳遞。
生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 国产精品二区在线 | www.国产精品 | 日韩在线二区 | 性欧美xxxx| 宅男天堂 | 国产又黄又爽又刺激的视频 | 99re最新视频 | 久久一 | 国产成人免费在线观看 | 免费看av大片 | 成人久久久| 伊人操| a级片网| 国产精品成av人在线视午夜片 | 99免费在线视频 | 精品久久久久久久久久久久久久久 | 久久精品亚洲一区二区 | 99久久精 | 亚洲欧美在线视频 | 国产精品入口免费视 | 少妇乱淫aaa高清视频真爽 | 免费黄色一级大片 | 精品久久99 | 91天天综合 | 国产成人在线播放 | 亚洲精品黄色 | 成年人xxx视频 | 欧美日韩不卡视频 | 精精国产xxxx视频在线野外 | 日韩免费中文字幕 | 波多野结衣精品在线 | 在线一二三区 | 成人在线国产 | 99精品视频在线观看视频 | 91精品久久久久久久 | 激情欧美日韩一区二区 | 91亚洲精品一区二区 | 成人看片在线观看 | 国产欧美一区二区三区在线看 | www国产亚洲精品久久网站 | 中文字幕一区二区三区免费视频 |