android - I am trying to implement a View Pager with controlled swiping.But I am getting a binary inflate exception on the custom view page -


i trying disable or enable viewpager's swiping custom viewpager..but getting inflating exception on viewpager .please me.

mainactivity

public class mainactivity extends fragmentactivity { timer timer; int page = 0; viewpager pager;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);          pager = (viewpager) findviewbyid(r.id.view_pager);     pager.setadapter(new mypageradapter(getsupportfragmentmanager()));       pager.setenabled(false);       //pageswitcher(3);     } 

////extending viewpager class

public class hackyviewpager extends viewpager {     private boolean enabled;     public hackyviewpager(context context) {         super(context);     }         public hackyviewpager(context context, attributeset attrs) {         super(context, attrs);         this.enabled = true;     }       @override     public boolean ontouchevent(motionevent event) {         if (this.enabled) {             return super.ontouchevent(event);         }          return false;     }      @override     public boolean onintercepttouchevent(motionevent event) {         if (this.enabled) {             return super.onintercepttouchevent(event);         }          return false;     }      public void setpagingenabled(boolean enabled) {         this.enabled = enabled;     } } 

activity_main xml

adding custom viewpager

     <com.example.qms.mainactivity.hackyviewpager      android:id="@+id/view_pager"       android:layout_width="match_parent"        android:layout_height="0dp"        android:layout_weight="2.5" />      # exception #   android.view.inflateexception: binary xml file line #32: error inflating        class com.example.qms.mainactivity.hackyviewpager                   

this hackyviewpager missed in mentioned package. please check if available.

you can android.support.v4.view.viewpager.

view pager


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -