Viewpager No sliding

Source: Internet
Author: User

Package Com.ofess.lottery.lottery.view;

Import Android.content.Context;
Import Android.support.v4.view.ViewPager;
Import Android.util.AttributeSet;
Import android.view.MotionEvent;

/**
* Created by Gateway on 2016/6/24.
*/
public class Myviewpager extends Viewpager {




Private Boolean iscanscroll = false;

Public Myviewpager (Context context) {
Super (context);
}

Public Myviewpager (context context, AttributeSet Attrs) {
Super (context, attrs);
}



Default cannot slide, set to True to slide

public void Setscanscroll (Boolean iscanscroll) {
This.iscanscroll = Iscanscroll;
}

@Override
public void ScrollTo (int x, int y) {
Super.scrollto (x, y);
}

@Override
public boolean ontouchevent (Motionevent arg0) {
TODO auto-generated Method Stub
if (Iscanscroll) {
Return super.ontouchevent (arg0);
} else {
return false;
}

}

@Override
public void Setcurrentitem (int item, Boolean smoothscroll) {
TODO auto-generated Method Stub
Super.setcurrentitem (item, Smoothscroll);
}

@Override
public void Setcurrentitem (int item) {
TODO auto-generated Method Stub
Super.setcurrentitem (item);
}

@Override
public boolean onintercepttouchevent (Motionevent arg0) {
TODO auto-generated Method Stub
if (Iscanscroll) {
Return super.onintercepttouchevent (arg0);
} else {
return false;
}

}


}

<yourpackeagename.indexviewpager        android:id= "@+id/vpager"        android:layout_width= "Wrap_content        " android:layout_height= "Wrap_content"        android:layout_gravity= "center"        android:layout_weight= "1.0"        Android:background= "#000000"        android:flipinterval= "android:persistentdrawingcache="        animation "/>


Reference from http://www.cnblogs.com/longhs/p/4173688.html

Viewpager No sliding

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.