Code example for ViewPager

Methods: getParent, getScrollX, onTouchEvent

0
     * 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();
                boolean result = super.onTouchEvent(ev);
                if (scrollX != getScrollX()) {
                    _isDragging = true;
                    return result;
                } else { 
                    getParent().requestDisallowInterceptTouchEvent(false); // let parent take over 
                    return false; 
                } 
            } 
        } 
         
        return super.onTouchEvent(ev);
    } 
}