Code example for ViewPager

Methods: getCurrentItem, setCurrentItem

0
    } 
 
    public boolean pageBackward(boolean smoothScroll) {
        if (mLock == LOCK_BOTH || mLock == LOCK_BACKWARD) return false;
 
        if (getCurrentItem() > 0) { 
            setCurrentItem(getCurrentItem() - 1, smoothScroll);
            return true; 
        } 
        return false; 
    } 
 
    public boolean pageToFirst(boolean smoothScroll) {
        if (mLock == LOCK_BOTH || mLock == LOCK_BACKWARD) return false;
 
        if (getCurrentItem() > 0) { 
            setCurrentItem(0, smoothScroll);
            return true; 
        } 
        return false; 
    }