我已经实现了 GestureListener,它工作得很好,但是如何从我的 View 中删除 GestureListener?
@Override
public boolean onTouchEvent(MotionEvent event) {
if ( event.getAction() == MotionEvent.ACTION_UP ) {
// remove gestureDetector
} else {
mGestureDetector.onTouchEvent(event);
}
return true;
}
问候, 尼尚沙阿
最佳答案
我不确定您所说的“删除 gestureDetector”是什么意思。
相反,您应该考虑先将 MotionEvent 传递给 GestureDetector,然后仅当 GestureDetector 不这样做时才自行处理事件,如下所示:
public boolean onTouchEvent(MotionEvent event) {
if (mGestureDetector.onTouchEvent(event)) {
return true;
}
<your code to process the event here>
}
关于android - 如何在 android 中禁用 GestureListener?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3371683/