Code example for ViewPager

Methods: onInterceptTouchEvent, getParent

0
     */ 
    @Override 
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        // Start of (possible) scroll gesture 
        if (ev.getActionMasked() == MotionEvent.ACTION_DOWN) {
            getParent().requestDisallowInterceptTouchEvent(true); // stop parent from intercepting the motion event                    
            _startX = ev.getX();
            _isDragging = false;
        } 
         
        return super.onInterceptTouchEvent(ev);
    } 
    
    /** 
     * Handle touch event. Don't let parent intercept event if we can scroll ourselves. 
     */ 
    public boolean onTouchEvent(MotionEvent ev) {
        if (!_isDragging && ev.getActionMasked() == MotionEvent.ACTION_MOVE) {
            if (_startX != ev.getX()) {
                int scrollX = getScrollX();
Connect your IDE to all the code out there  Get Codota for Java