0

I just made a Countdowntimer and a Progressbar :

public void button1_onClick (View view) {
mCountDownTimer=new CountDownTimer(10000,1000) {

    @Override
    public void onTick(long millisUntilFinished) {
        Log.v("Log_tag", "Tick of Progress"+ i+ millisUntilFinished);
        i++;
        mProgressBar.setProgress(i);

    }

    @Override
    public void onFinish() {
        i++;
        mProgressBar.setProgress(i);
        game_end();
    }
};

 mCountDownTimer.start();
}
 public void button2_reset_onClick (View view) {
   mProgressBar.setProgress(0); }

It is also working but when I try to start it a second time I get no animation ? It counts until 10 but I cannot see it on the Progressbar... How can I reset the Progressbar properly ? I allready tried to make i = 0 but it doesnt helped

user3339279
  • 163
  • 3
  • 12

2 Answers2

0
mProgressBar.setProgress(i);
if(i == 0) {
mProgressBar.setProgress(100);  
}

if you want your counter automatically restarts when it reaches 0 uses this. otherwise do the opposite

Gapp Aiello
  • 182
  • 1
  • 15
0

Where are you dismissing the progress bar. That internally calls the reset function of the progress bar and that will reset it to 0 for you.

Mobility
  • 263
  • 2
  • 5