I solved a similar problem using GestureDetector
Submitting a MotionEvent to the GestureDetector
tapGestureDetector = new GestureDetector(this, new TapGestureListener()); viewPager.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { tapGestureDetector.onTouchEvent(event); return false; } });
This is you using the compatibility library, you can change the first line to:
tapGestureDetector = new GestureDetectorCompat(this, new TapGestureListener());
You can handle your event in the GestureListener:
class TapGestureListener extends GestureDetector.SimpleOnGestureListener{ @Override public boolean onSingleTapConfirmed(MotionEvent e) {
Martin Christmann Jul 26 2018-12-12T00: 00Z
source share