1

I have 3 fragments loaded with a ViewPager.

One of the fragments has a ProgressBar being updated like so:

cdt = new CountDownTimer(intDuration, 1000) { //(intDuration) milli seconds is total time, 1000 milli seconds is time interval

    public void onTick(long millisUntilFinished) {
        pb.setProgress(pb.getProgress() + 1);
    }
    public void onFinish() { }
}.start();

This works great until I swipe to another fragment, then of course the time stops.

How can I get the timer to continue to run while the fragment is not in focus, so that the ProgressBar is in the correct position when returning to the fragment?

stkent
  • 19,772
  • 14
  • 85
  • 111
Rival
  • 99
  • 1
  • 10
  • http://stackoverflow.com/questions/6787071/android-fragment-how-to-save-states-of-views-in-a-fragment-when-another-fragmen – Rishad Appat May 31 '15 at 14:07

1 Answers1

1

Try this:

mViewPager.setOffscreenPageLimit(3);

This retains your fragment even if they're not on screen.

razzledazzle
  • 6,900
  • 4
  • 26
  • 37