0
我正在做一个倒计时的Android游戏。倒数计时完美,但问题是,当我暂停游戏时(我停止绘制表面视图),倒计时继续。暂停CountDown计时器Android
new CountDownTimer(60000, 1000) {
public void onTick(long millisUntilFinished) {
timer = String.valueOf(millisUntilFinished/1000);
invalidate();
}
public void onFinish() {
}
}.start();
如何暂停倒计时?
http://stackoverflow.com/questions/10362014/countdown-timer-with-pause-and-resume –
或http://stackoverflow.com/a/9663508/794088 – petey
一个合适的解决方案是编写你自己的支持暂停和恢复的'CountDownTimer'版本。不要使用'TimerTask',因为这是创建后台线程,你不能从那里触摸UI。 – zapl