java countdowntimer - 计时器de contagem regressiva

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java countdowntimer - 计时器de contagem regressiva相关的知识,希望对你有一定的参考价值。


    private void startCountdown() {
        final SimpleDateFormat df = new SimpleDateFormat("mm:ss");
        buttonSendCode.setEnabled(false);

        if(countDownTimer != null) countDownTimer.cancel();

        countDownTimer = new CountDownTimer(MILLISECONDS_TO_RESEND, 1000) {
            public void onTick(long millisUntilFinished) {
                buttonSendCode.setText(df.format(new Date(millisUntilFinished)));
            }

            public void onFinish() {
                buttonSendCode.setText(getString(R.string.resend_code));
                buttonSendCode.setEnabled(true);
            }
        }.start();
    }

以上是关于java countdowntimer - 计时器de contagem regressiva的主要内容,如果未能解决你的问题,请参考以下文章