Code example for ViewPager

Methods: getCurrentItem, setCurrentItem

0
    } 
 
    public boolean pageToFirst(boolean smoothScroll) {
        if (mLock == LOCK_BOTH || mLock == LOCK_BACKWARD) return false;
 
        if (getCurrentItem() > 0) { 
            setCurrentItem(0, smoothScroll);
            return true; 
        } 
        return false; 
    } 
 
    public boolean pageToLast(boolean smoothScroll) {
        if (mLock == LOCK_BOTH || mLock == LOCK_FORWARD || getAdapter() == null) return false;
 
        if (getCurrentItem() != getAdapter().getCount() - 1) { 
            setCurrentItem(getAdapter().getCount() - 1, smoothScroll);
            return true; 
        } 
        return false; 
    }