@Override public boolean onTouchEvent(MotionEvent ev){
  final int action=ev.getAction();
  final int x=(int)ev.getX();
  if (action == MotionEvent.ACTION_DOWN) {
    mDragMode=true;
    if (!mScroller.isFinished()) {
      mScroller.abortAnimation();
    }
  }
  if (!mDragMode)   return super.onTouchEvent(ev);
  if (mVelocityTracker == null) {
    mVelocityTracker=VelocityTracker.obtain();
  }
  mVelocityTracker.addMovement(ev);
switch (action) {
case MotionEvent.ACTION_DOWN:
    break;
case MotionEvent.ACTION_MOVE:
  mScrollX+=mLastX - x;
reScrollTo(mScrollX,0,true);
break;
case MotionEvent.ACTION_UP:
final VelocityTracker velocityTracker=mVelocityTracker;
velocityTracker.computeCurrentVelocity(1000);
int initialVelocity=(int)Math.min(velocityTracker.getXVelocity(),mMaximumVelocity);
if (getChildCount() > 0 && Math.abs(initialVelocity) > mMinimumVelocity) {
fling(-initialVelocity);
}
mDragMode=false;
default :
return false;
}
mLastX=x;
return true;
}

@ Override public boolean onTouchEvent ( MotionEvent ev ) { final int action = ev . getAction ( ) ; final int x = ( int ) ev . getX ( ) ; if ( action == MotionEvent . ACTION_DOWN ) { mDragMode = true ; if ( ! mScroller . isFinished ( ) ) { mScroller . abortAnimation ( ) ; } } if ( ! mDragMode ) return super . onTouchEvent ( ev ) ; if ( mVelocityTracker == null ) { mVelocityTracker = VelocityTracker . obtain ( ) ; } mVelocityTracker . addMovement ( ev ) ; switch ( action ) { case MotionEvent . ACTION_DOWN : break ; case MotionEvent . ACTION_MOVE : mScrollX += mLastX - x ; reScrollTo ( mScrollX , 0 , true ) ; break ; case MotionEvent . ACTION_UP : final VelocityTracker velocityTracker = mVelocityTracker ; velocityTracker . computeCurrentVelocity ( 1000 ) ; int initialVelocity = ( int ) Math . min ( velocityTracker . getXVelocity ( ) , mMaximumVelocity ) ; if ( getChildCount ( ) > 0 && Math . abs ( initialVelocity ) > mMinimumVelocity ) { fling ( - initialVelocity ) ; } mDragMode = false ; default : return false ; } mLastX = x ; return true ; }
finding whether to scroll or not
