android - Continue updating ProgressBar when ViewPager Fragment is off screen -


i have 3 fragments loaded viewpager.

one of fragments has progressbar being updated so:

cdt = new countdowntimer(intduration, 1000) { //(intduration) milli seconds total time, 1000 milli seconds time interval      public void ontick(long millisuntilfinished) {         pb.setprogress(pb.getprogress() + 1);     }     public void onfinish() { } }.start(); 

this works great until swipe fragment, of course time stops.

how can timer continue run while fragment not in focus, progressbar in correct position when returning fragment?

try this:

mviewpager.setoffscreenpagelimit(3); 

this retains fragment if they're not on screen.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -