Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to prevent ListView scrolling while touching/swiping/fling its row?
    text
    copied!<p>I need to stop ListView to respond on user gestures if those gestures are made in some particular ListView's row - How to do that? Target ListView's row view has onTouchListener set and I cant recognize swipe/flip because of ListView up/down scroll. So if I move finger a bit up or down - ListView intercepts that and scrolls in corresponding direction. So I need somehow to rule it like if Y-coord chaged more than some amount - let ListView to scroll and if not - recognize a gesture as fling/swipe. OnTouchListener is</p> <pre><code>private int SWIPE_MIN_DISTANCE = 1; private int SWIPE_MAX_OFF_PATH = 300; final OnTouchListener flingSwipeListener = new OnTouchListener() { float touchX; float touchY; @Override public boolean onTouch(final View view, final MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { touchX = event.getX(); touchY = event.getY(); } else if (event.getAction() == MotionEvent.ACTION_UP) { if (Math.abs(touchY - event.getY()) &gt; SWIPE_MAX_OFF_PATH) return false; // right to left swipe else if (touchX - event.getX() &gt; SWIPE_MIN_DISTANCE){ Log.i("flingSwipe","right to left swipe"); } // left to right swipe else if (event.getX() - touchX &gt; SWIPE_MIN_DISTANCE){ Log.i("flingSwipe","left to right swipe"); } } return true; } }; </code></pre> <p>This onTouchListner was set to one particular row. I need to freeze ListView while onTouchListener recognizes the gesture but if it fails I need to send the MotionEvent to the ListView.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload