Code example for ViewPager

Methods: getParent, onInterceptTouchEvent

0
        mTouchSlop = (viewConfiguration.getScaledTouchSlop());
    } 
 
    @Override 
    public boolean onInterceptTouchEvent(MotionEvent event) {
        super.onInterceptTouchEvent(event);
        final int action = event.getAction();
        if (action == MotionEvent.ACTION_DOWN) {
            mCurrX = event.getX();
            mCurrY = event.getY();
            mStartX = event.getX();
            mStartY = event.getY();
            getParent().requestDisallowInterceptTouchEvent(true); 
        } else if (Math.abs(event.getY() - mStartY) > Math.abs(event.getX() - mStartX)) {
            // User scrolled vertically 
            getParent().requestDisallowInterceptTouchEvent(false); 
        } else if (action == MotionEvent.ACTION_MOVE) {
            // Shouldn't need to do anything 
        } else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
            getParent().requestDisallowInterceptTouchEvent(false); 
        } else { 
            getParent().requestDisallowInterceptTouchEvent(true); 
        } 
        return super.onInterceptTouchEvent(event);
    } 
 
    @Override 
    public boolean onTouchEvent(MotionEvent event) {
        final int action = event.getAction();