Skip to content

Instantly share code, notes, and snippets.

@amyu
Created December 4, 2014 08:00
Show Gist options
  • Save amyu/f80c521a71c3cc90d96b to your computer and use it in GitHub Desktop.
Save amyu/f80c521a71c3cc90d96b to your computer and use it in GitHub Desktop.
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;
/**
* Created by amyu on 2014/12/4.
*/
public class NoSwipeViewPager extends ViewPager {
private boolean mIsSwipe = false;
public NoSwipeViewPager(Context context) {
super(context);
}
public NoSwipeViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
}
public void setSwipe(boolean flag) {
mIsSwipe = flag;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return mIsSwipe && super.onTouchEvent(event);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
return mIsSwipe && super.onInterceptTouchEvent(event);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment