Code example for ViewPager

Methods: getAdapter, getCurrentItem, setCurrentItem

0
    } 
 
    public boolean pageForward(boolean smoothScroll) {
        if (mLock == LOCK_BOTH || mLock == LOCK_FORWARD) return false;
 
        if (getAdapter() != null && getCurrentItem() < (getAdapter().getCount() - 1)) { 
            setCurrentItem(getCurrentItem() + 1, smoothScroll);
            return true; 
        } 
        return false; 
    } 
 
    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; 
    }