Last active
July 19, 2016 09:33
-
-
Save dGorod/7b884c76901427904a7fa7225b7fca05 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import android.content.Context; | |
import android.support.v4.view.ViewPager; | |
import android.util.AttributeSet; | |
import android.view.MotionEvent; | |
/** | |
* Created by Dmitriy Gorodnytskiy on 24-Sep-15. | |
*/ | |
public class NonSwipeableViewPager extends ViewPager { | |
private boolean swipe = false; | |
public boolean isSwipeable() { | |
return swipe; | |
} | |
public void setSwipeable(boolean swipe) { | |
this.swipe = swipe; | |
} | |
public NonSwipeableViewPager(Context context) { | |
super(context); | |
} | |
public NonSwipeableViewPager(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
} | |
@Override | |
public boolean onInterceptTouchEvent(MotionEvent arg0) { | |
if (swipe) { | |
return super.onInterceptTouchEvent(arg0); | |
} | |
// 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