Created
November 1, 2017 17:03
-
-
Save afiqiqmal/99b5d709c14257059590ab25016d3b15 to your computer and use it in GitHub Desktop.
This is for to block swipe of 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
import android.content.Context; | |
import android.support.v4.view.ViewPager; | |
import android.util.AttributeSet; | |
import android.view.MotionEvent; | |
/** | |
* @author : hafiq on 07/02/2017. | |
*/ | |
public class BlockPager extends ViewPager { | |
boolean block = false; | |
public BlockPager(Context context) { | |
super(context); | |
} | |
public BlockPager(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
} | |
public void setBlock(boolean block) { | |
this.block = block; | |
} | |
@Override | |
public boolean onInterceptTouchEvent(MotionEvent ev) { | |
return !block && super.onInterceptTouchEvent(ev); | |
} | |
@Override | |
public boolean onTouchEvent(MotionEvent ev) { | |
return !block && super.onTouchEvent(ev); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment