Inherited from Viewpager can be used together with Photoview, to achieve the photo album picture left and right slide, zoom out, etc.
Package Davidwang.tm.view;import Android.content.context;import android.support.v4.view.viewpager;import Android.util.attributeset;import android.view.MotionEvent;/** * Found atHttp://stackoverflow.com/questions/7814017/is-it-possible-to-disable-scrolling-on-a-viewpager.* Convenient-temporarily disable Viewpager navigation while interacting with ImageView. * Julia Zudikova
*//** * hacky fix for Issue #4 and *http://code.google.com/p/android/issues/detail?id=18990* <p/> * Scalegesturedetector seems to mess up the touch events, which means this * viewgroups which make use O F Onintercepttouchevent throw a lot of * illegalargumentexception:pointerindex out of range. * <p/> * there ' s not much I can does in my code for now, but we can mask the result by * just catching the problem and Ignoring it. * * @author Chris banes*/ Public classHackyviewpager extends Viewpager {PrivateBoolean isLocked; PublicHackyviewpager (Context context) {super (context); IsLocked=false; } PublicHackyviewpager (Context context, AttributeSet Attrs) {Super (context, attrs); IsLocked=false; } @Override Publicboolean onintercepttouchevent (motionevent ev) {if(!isLocked) { Try { returnsuper.onintercepttouchevent (EV); } Catch(IllegalArgumentException e) {e.printstacktrace (); return false; } } return false; } @Override PublicBoolean ontouchevent (motioneventEvent) { if(!isLocked) { returnSuper.ontouchevent (Event); } return false; } Public voidTogglelock () {isLocked= !isLocked; } Public voidsetlocked (Boolean isLocked) { This. isLocked =isLocked; } PublicBoolean isLocked () {returnisLocked; } }
What's the use of Hackyviewpager?