Code example for ViewPager

Methods: getContext

0
        super(context, attrs);
        init(); 
    } 
 
    private void init() { 
        ViewConfiguration viewConfiguration = ViewConfiguration.get(getContext());
        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