0

I want to implement a non-scrollable ViewPager. People say that I should override the onInterceptTouchEvent and onTouchEvent functions:

@Override
public boolean onTouchEvent(MotionEvent event) {
    if (this.enabled) {
        return super.onTouchEvent(event);
    }

    return false;
}

@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
    if (this.enabled) {
        return super.onInterceptTouchEvent(event);
    }

    return false;
}

Okay, I can't swipe now. But I need the taps that are gone too! Both of them are MotionEvents with action=ACTION_DOWN, so how can I differentiate one from another and pass only taps in this case?

P. S. What the hell? In iOS I can disable scrolling by unchecking one checkmark.

Community
  • 1
  • 1
efpies
  • 3,625
  • 6
  • 34
  • 45

1 Answers1

0

The answer is that sweep is a continuous touch gesture that starts with ACTION_DOWN and ends with ACTION_UP. So I can pass touch only with action=ACTION_DOWN

@Override
public boolean onTouchEvent(MotionEvent event) {
    if (this.enabled || event.getAction() == MotionEvent.ACTION_DOWN) {
        return super.onTouchEvent(event);
    }

    return false;
}
efpies
  • 3,625
  • 6
  • 34
  • 45