【发布时间】:2018-06-26 18:41:39
【问题描述】:
我的倒数计时器有问题。我尝试了本网站上的一些解决方案和文章,但它们对我没有用。所以,请阅读我的代码...
我也用过
handler.postDelayed(new Runnable() {
之前,这不是我的解决方案,但它工作正常。
主要问题是:
我想做如下的事情:
(button pressed)
do some codes1
delay1
do other codes2
delay2
go back to *do some codes1* again.
简而言之,这是我的真实代码:
itimesec--;
setdelay();
irepeat--;
setrelax();
这是我的功能:
public void setrelax(){
CountDownTimer yourCountDownTimer1 = new CountDownTimer(50000, 1000) {
public void onTick(long millisUntilFinished1) {
itotalsnozee--;
TextToSpeechFunction(" "+itotalsnozee);
}
public void onFinish() {
itotalsnozee=fitotalsnozee;
isrelax=false;
TextToSpeechFunction("do again");
}
}.start();
yourCountDownTimer1.cancel();
}
我尝试使用 50000 的变量,但无论如何都没有用。
我尝试将 setrelax 功能代码直接放入 oncreate 中,但没有成功。 它刚刚跳到
}.start();
yourCountDownTimer1.cancel();
每次都出去。
我尝试了所有代码,没有任何延迟功能,它们运行正确。
请问我怎么了……
【问题讨论】:
标签: android countdowntimer timedelay postdelayed