public void setCurrentPosition ( int position , boolean smooth ) { if ( getRealAdapter ( ) == null ) throw new IllegalStateException ( "You did not set a slider adapter" ) ; if ( position >= getRealAdapter ( ) . getCount ( ) ) { throw new IllegalStateException ( "Item position is not exist" ) ; } int p = mViewPager . getCurrentItem ( ) % getRealAdapter ( ) . getCount ( ) ; int n = ( position - p ) + mViewPager . getCurrentItem ( ) ; mViewPager . setCurrentItem ( n , smooth ) ; }
set current slider