Code example for Scroller

Methods: abortAnimation, getCurrX, isFinished, setFinalX, startScroll

0
				resetTo(resetToWhere()); 
			} 
		} 
		 
		public boolean isNeedReset(){ 
			int cx = mScroller.getCurrX(); 
			return cx != 0 && cx != pLeftBound && cx != pRightBound;
		} 
		 
 		public Position resetToWhere(){ 
			if (Math.abs(mScroller.getCurrX()) > pCenterPosition) {
				if (mScroller.getCurrX()>0) {
					return Position.LEFT;
				}else { 
					return Position.RIGHT;
				} 
			}else { 
				return Position.CENTER;
			} 
		} 
		 
 		public void resetTo(Position resetToPosition){
 			switch (resetToPosition) {
			case LEFT:
				resetToLeft(); 
				break; 
			case CENTER:
				resetToCenter(); 
				break; 
			case RIGHT:
				resetToRight(); 
				break; 
			default: 
				break; 
			} 
 		} 
		 
		 
		public void resetToLeft(){ 
			if (!mScroller.isFinished()) {
				mScroller.abortAnimation();
			} 
			mScroller.startScroll(mScroller.getCurrX(), 0, 0,0,pScrollDuration/2);
			mScroller.setFinalX(pScrollToRight);
			invalidate();
			 
			pPosition = Position.LEFT;
			pState = State.FLING;
		} 
		 
		public void resetToRight(){ 
			if (!mScroller.isFinished()) {
				mScroller.abortAnimation();
			} 
			mScroller.startScroll(mScroller.getCurrX(), 0, 0,0,pScrollDuration/2);
			mScroller.setFinalX(pScrollToLeft);
			invalidate();
			 
			pPosition = Position.RIGHT;
			pState = State.FLING;
		} 
		 
		public void resetToCenter(){ 
			if (!mScroller.isFinished()) {
				mScroller.abortAnimation();
			} 
			mScroller.startScroll(mScroller.getCurrX(), 0, 0,0,pScrollDuration/2);
			mScroller.setFinalX(0);
			invalidate();
			 
			pState = State.FLING;
			pPosition = Position.CENTER;
		}