Detecting horizontal swipe in ListView
<p>I need to detect a horizontal swipe within a list view.  Should I use a gesture detector or onTouch event.  I need to support Android 2.1+</p>

<p>One post indicated the need to override onInterceptTouchEvent in the ListView  like below:</p>

<pre><code> @Override public boolean onInterceptTouchEvent(MotionEvent ev) { 
    switch (ev.getAction()) {  case   MotionEvent.ACTION_DOWN: // reset difference values mDiffX = 0; mDiffY = 0;

        mLastX = ev.getX();
        mLastY = ev.getY();
        break;

    case MotionEvent.ACTION_MOVE:
        final float curX = ev.getX();
        final float curY = ev.getY();
        mDiffX += Math.abs(curX - mLastX);
        mDiffY += Math.abs(curY - mLastY);
        mLastX = curX;
        mLastY = curY;

        // don't intercept event, when user tries to scroll vertically
        if (mDiffX &gt; mDiffY) {
            return false; // do not react to horizontal touch events, these events will be passed to your list item view
        }
}

return super.onInterceptTouchEvent(ev);
}
</code></pre>

<p>Not sure if this works or is the best way however.  It did not help that the question was mindlessly closed 8 days ago:  <a href="http://stackoverflow.com/questions/11647276/swipe-gesture-inside-listview-android?rq=1">Swipe Gesture inside ListView - Android</a></p>
