I have read the post: Fling gesture detection on grid layout and implemented gesture detection. But I have the follow problem. After the action onFling() occurred, the onListItemClick() is calling. How to fix this problem?
Asked
Active
Viewed 530 times
2 Answers
0
You can try
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
view.requestDisallowInterceptTouchEvent(true);
.....
view.requestDisallowInterceptTouchEvent(false);
}
Maybe helps

Vyacheslav Shylkin
- 9,741
- 5
- 39
- 34
0
The problem was in the onFling() method. This method should return true if operation completed successfully, otherwise calls 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;
}

Alex Kucherenko
- 20,168
- 2
- 26
- 33