0
基本上我正在做一个有氧运动的功能,并有一个嵌套在一个行内的三个倒计时定时器,所以当一个定时器完成后,下一个定时器开始。准备时间一个,锻炼时间一个,休息时间一个,用户选择这些时间。倒计时器不循环
我需要它循环但用户从numberpicker中选择多次,但无论我做什么,它只会经历一次,不循环,所以我知道它的一切工作,它只是循环的一部分,工作。
我在这里错过了什么吗?有一个更好的方法吗?
//Main countdown timers loop
for(int i = 0; i <= times.getValue() + 1; i++) //times NumberPicker
{
prepCountTimer = new CountDownTimer(_finalPrep * 1000, 1000) {
public void onTick(long millisUntilFinished) {
tvRoundCount.setText("Round " + roundCount + "/" + times.getValue());
tvCountDown.setText((millisUntilFinished/1000) + "s");
if(millisUntilFinished <= (6 * 1000))
{
tvCountDown.setTextColor(Color.RED);
}
}
public void onFinish() {
workoutCountTimer = new CountDownTimer(_finalWorkout * 1000, 1000) {
public void onTick(long millisUntilFinished) {
tvCountDown.setTextColor(Color.GREEN);
tvCountDown.setText((millisUntilFinished/1000) + "s");
if(millisUntilFinished <= 6 * 1000)
{
tvCountDown.setTextColor(Color.RED);
}
}
public void onFinish() {
restCountTimer = new CountDownTimer(_finalRest * 1000, 1000) {
public void onTick(long millisUntilFinished) {
tvCountDown.setTextColor(Color.GREEN);
tvCountDown.setText((millisUntilFinished/1000) + "s");
if(millisUntilFinished <= 6 * 1000)
{
tvCountDown.setTextColor(Color.RED);
}
}
public void onFinish() {
roundCount = roundCount + 1;
}
}.start();
}
}.start();
}
}.start();
}
我该怎么做?我不明白为什么它不会根据用户选择的重复x次... – user1875797 2013-02-15 21:08:51
我已经编辑了我的答案,以显示您可能会如何做到这一点。 – Eluvatar 2013-02-15 21:37:46