Android 如果发生gestureDetector操作,如何禁用onListItemClick()操作
我读过帖子:并实现了手势检测。但我有以下问题。在onFling()操作发生后,onListItemClick()正在调用。如何解决这个问题 你可以试试Android 如果发生gestureDetector操作,如何禁用onListItemClick()操作,android,touch-event,gesture-recognition,ontouchlistener,Android,Touch Event,Gesture Recognition,Ontouchlistener,我读过帖子:并实现了手势检测。但我有以下问题。在onFling()操作发生后,onListItemClick()正在调用。如何解决这个问题 你可以试试 public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { view.requestDisallowInterceptTouchEvent(true); ..... view.requestDisallowI
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
view.requestDisallowInterceptTouchEvent(true);
.....
view.requestDisallowInterceptTouchEvent(false);
}
可能有帮助问题出在onFling()方法中。如果操作成功完成,则此方法应返回true,否则调用onClickItemClicked()
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2,
float velocityX, float velocityY) {
if (e2.getAction()!=MotionEvent.ACTION_UP){
return false;
}
try {
float diffAbs = Math.abs(e1.getY() - e2.getY());
float diff = e1.getX() - e2.getX();
if (diffAbs > SWIPE_MAX_OFF_PATH)
return false;
// Left swipe
if (diff > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
listener.onLeftSwipe();
// Right swipe
} else if (-diff > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
listener.onRightSwipe();
}
return true;
} catch (Exception e) {
}
return false;
}