码迷,mamicode.com
首页 > 移动开发 > 详细

Android ViewGroup onInterceptTouchEvent

时间:2014-07-22 23:07:55      阅读:537      评论:0      收藏:0      [点我收藏+]

标签:android   des   http   io   for   re   

public boolean onInterceptTouchEvent (MotionEvent ev)

  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:

  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.

  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().

  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 ACTION_CANCEL, and all further events will be delivered to your onTouchEvent() method and no longer appear here.

 

返回false(默认),则所有事件从onInterceptTouchEvent 再到onTouchEvent

返回true,则所有事件只传递到onTouchEvent

Android ViewGroup onInterceptTouchEvent,码迷,mamicode.com

Android ViewGroup onInterceptTouchEvent

标签:android   des   http   io   for   re   

原文地址:http://www.cnblogs.com/yuyutianxia/p/3700476.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!