我想在我的应用程序中使用 countDown 计时器,我应该创建如下: Click too see image
如何创建countDownTimer,如上面的设计?
答案 0 :(得分:0)
在文本字段中显示30秒倒计时的示例:
new CountDownTimer(30000, 1000) {
public void onTick(long millisUntilFinished) {
mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);
}
public void onFinish() {
mTextField.setText("done!");
}
}.start();
访问https://developer.android.com/reference/android/os/CountDownTimer.html
答案 1 :(得分:0)
答案 2 :(得分:0)
private void downTimer(){
new CountDownTimer(120*1000,1000) {
@Override
public void onTick(long millisUntilFinished) {
long second = (millisUntilFinished / 1000) % 60;
long minutes = (millisUntilFinished/(1000*60)) % 60;
textViewCountDownTimer.setText(minutes + ":" + second);
}
@Override
public void onFinish() {
textViewCountDownTimer.setText("Finish");
}
}.start();
}