android - ViewPager AutoScroll not Working Properly -


android viewpager autoscroll not working using scheduleatfixedrate.

this code,is right ?

  protected void startautoscroll() {     swipetimer=new timer();     swipetimer.scheduleatfixedrate(new timertask() {          @override         public void run() {              new handler(looper.getmainlooper()).post(new runnable() {                  @override                 public void run() {                     if(currentposition==shalombannerslist.size())                     {                         currentposition=0;                     }                          viewpager.setcurrentitem(currentposition,true);                      currentposition=currentposition+1;                  }             });          }     }, 100, 4000);  } 

please me.

try code :

int page=0; public void pageswitcher() {      timer timer = new timer();     timer.scheduleatfixedrate(new remindtask(), 1000, 3000); }  class remindtask extends timertask {      @override     public void run() {         mactivity.runonuithread(new runnable() {             public void run() {                 if (page > bannerslist.size()) {                     page = 0;                     viewpager.setcurrentitem(page++);                 } else {                     viewpager.setcurrentitem(page++);                 }             }         });     } } 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -