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