horizontalscrollview - Auto Scrolling of horizontal list items with timer in android -
i need show advertisements in app datas fetched web services. have displayed ads in horizontal listview. want each cell of listview scrolled automatically @ particular time interval (as google ads). how can ?
the best way, think, use handler in activity, or fragment. add code this:
private handler handler = new handler(); handler.postdelayed(runnable, interval);
and in runnable should implement scrolling of listview.
update if use viewpager instead of scrollview can make way:
final handler handler = new handler(); runnable runable = new runnable() { @override public void run() { //this select next page number page = page==maxpages? 0 : ++page; //this change page concrete page number viewpager.setcurrentitem(page); //this execute code after timeinterval handler.postdelayed(this, timeinterval); } }; handler.postdelayed(runable, timeinterval);
where viewpager
viewpager instance, timeinterval
- time interval in milliseconds after want scroll page, maxpages
- number of last page have in viewpager
Comments
Post a Comment