Code example for ViewPager

-2
public class MyViewPager extends ViewPager { 
 
    private GestureDetector gestureDetector;
 
    public MyViewPager(Context context) {
        super(context);
    } 
 
    public MyViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    } 
 
    public void setGestureDetector(GestureDetector gestureDetector) {
        this.gestureDetector = gestureDetector;
    } 
 
    @Override 
    public boolean onTouchEvent(MotionEvent ev) {
        if (this.gestureDetector != null)
            this.gestureDetector.onTouchEvent(ev);