Back to project page DynamicViewPager.
The source code is released under:
Apache License
If you think the Android project DynamicViewPager listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package de.wackernagel.android.dynamicviewpager.view; /* ww w.j a v a 2s.c om*/ import de.wackernagel.android.dynamicviewpager.Lockable; import android.content.Context; import android.support.v4.view.ViewPager; import android.util.AttributeSet; import android.view.MotionEvent; public class LockableViewPager extends ViewPager implements Lockable { private boolean locked; public LockableViewPager( final Context context ) { super(context); unlockSwiping(); } public LockableViewPager( final Context context, final AttributeSet attrs ) { super(context, attrs); unlockSwiping(); } @Override public boolean onTouchEvent( MotionEvent event ) { if( !isLocked() ) { return super.onTouchEvent( event ); } return false; } @Override public boolean onInterceptTouchEvent( MotionEvent event ) { if( !isLocked() ) { return super.onInterceptTouchEvent( event ); } return false; } @Override public void lockSwiping() { this.locked = true; } @Override public void unlockSwiping() { this.locked = false; } @Override public void toggleLock() { this.locked = !isLocked(); } @Override public boolean isLocked() { return locked; } }