Created
December 5, 2014 08:47
-
-
Save gouravd/66ccfbbe71fe17171c92 to your computer and use it in GitHub Desktop.
Disable Swiping in ViewPager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/**** | |
*** use this class NonSwipeableViewPager instead of the standard ViewPager | |
****/ | |
package com.groupshoppy.helpers; | |
import android.content.Context; | |
import android.support.v4.view.ViewPager; | |
import android.util.AttributeSet; | |
import android.view.MotionEvent; | |
public class NonSwipeableViewPager extends ViewPager { | |
public NonSwipeableViewPager(Context context) { | |
super(context); | |
} | |
public NonSwipeableViewPager(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
} | |
@Override | |
public boolean onInterceptTouchEvent(MotionEvent arg0) { | |
// Never allow swiping to switch between pages | |
return false; | |
} | |
@Override | |
public boolean onTouchEvent(MotionEvent event) { | |
// Never allow swiping to switch between pages | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment