[英]How to make CountDownTimer count to 1?
How do I make CountDownTimer count to 1 , not 0 ? 如何使CountDownTimer计数为1 ,而不是0 ? How do I do that? 我怎么做? ( ͡° ͜ʖ ͡°) (͡°͜ʖ͡°)
private void start() {
countDownTimer = new CountDownTimer(3000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
time.setText("" + millisUntilFinished / 1000);
}
@Override
public void onFinish() {
time.setText("Click!");
}
};
countDownTimer.start();
}
Instead of starting from 4000 ms, start from 3000 ms, and add +1 before setting to TextView
: 而不是从4000毫秒开始,从3000毫秒开始,并在设置为TextView
之前添加+1:
private void start() {
countDownTimer = new CountDownTimer(3000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
time.setText(String.valueOf((int) Math.ceil(millisUntilFinished / 1000.0)));
}
@Override
public void onFinish() {
time.setText("Click!");
}
};
countDownTimer.start();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.