简体   繁体   English

Android-dispatchTouchEvent 没有捕捉到 ACTION_CANCEL

[英]Android-dispatchTouchEvent is not catching ACTION_CANCEL

I am overriding dispatchTouchEvent() method to detect each and every touch in an activity.我正在覆盖 dispatchTouchEvent() 方法来检测活动中的每个触摸。

 @Override
public boolean dispatchTouchEvent(MotionEvent event) {
    System.out.println("android test "+event.toString());
    return super.dispatchTouchEvent(event);
}

But this method is catching only ACTION_UP,ACTION_DOWN and ACTION_MOVE events,not ACTION_CANCEL event.但是这个方法只捕获 ACTION_UP、ACTION_DOWN 和 ACTION_MOVE 事件,而不是 ACTION_CANCEL 事件。 What may be the reason for this ?这可能是什么原因?

@pskink's answer is correct. @pskink 的回答是正确的。 ie ACTION_CANCEL is a system event.即 ACTION_CANCEL 是一个系统事件。

"ACTION_CANCEL occurs when the parent takes possession of the motion, for example when the user has dragged enough across a list view that it will start scrolling instead of letting you press the buttons inside of i. “ACTION_CANCEL 发生在父级控制动作时,例如当用户在列表视图中拖动足够多的时候它会开始滚动而不是让你按下 i 中的按钮。

http://developer.android.com/reference/android/view/ViewGroup.html#onInterceptTouchEvent%28android.view.MotionEvent%29 http://developer.android.com/reference/android/view/ViewGroup.html#onInterceptTouchEvent%28android.view.MotionEvent%29

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM