What's the use of Hackyviewpager?

Source: Internet
Author: User

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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.