Code example for ViewPager

Methods: getAdaptergetCurrentItemonTouchEvent, getParent

0
    public boolean onTouchEvent(MotionEvent event) {
        final int action = event.getAction();
        if (action == MotionEvent.ACTION_DOWN) {
            //mCurrX = event.getX(); 
        } else if (action == MotionEvent.ACTION_MOVE) {
            if (getCurrentItem() == 0 && ((event.getX() - mCurrX) > mTouchSlop)) {
                // User moved finger to the right and is on the leftmost ViewGroup 
                getParent().requestDisallowInterceptTouchEvent(false); 
            } else if (getCurrentItem() == (getAdapter().getCount() - 1) && ((mCurrX - event.getX()) > mTouchSlop)) {
                // User moved finger to the left and is on the rightmost ViewGroup 
                getParent().requestDisallowInterceptTouchEvent(false); 
            } else if (Math.abs(event.getY() - mCurrY) > Math.abs(event.getX() - mCurrX)) {
                // User scrolled vertically 
                getParent().requestDisallowInterceptTouchEvent(false); 
            } 
        } 
        return super.onTouchEvent(event);
    } 
} 
Connect your IDE to all the code out there  Get Codota for Java