问题
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
回答1:
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
回答2:
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.
来源:https://stackoverflow.com/questions/21971627/how-can-i-reset-the-progressbar