我不知道如何增加額外的時間,正在運行的計時器。 Evertime我按下一個按鈕我想添加1秒。 所以我的問題是,我該怎麼做?我如何添加額外的時間到一個定時器在android
這裏是我的定時器(代碼):
private void TimerGame(){
new CountDownTimer(15000, 1000) {
TextView mTextField = (TextView) findViewById(R.id.timeTv);
Button start = (Button)findViewById(R.id.startGameBtn);
TextView go = (TextView)findViewById(R.id.tvGo);
public void onTick(long millisUntilFinished) {
mTextField.setText("" +millisUntilFinished/1000);
}
public void onFinish() {
mTextField.setText("15");
start.setVisibility(View.VISIBLE);
go.setVisibility(View.INVISIBLE);
reset();
}
}.start();
}
在這種情況下,我會建議你做一個自定義的實現,而不是使用CountDownTimer,你有沒有考慮這樣的方法? – dwbrito
除了我添加的自定義實現之外,您可以複製正在使用的CountdownTimer並創建一個方法來延長停止的時間。 – dwbrito