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
Post a Comment