Android倒计时

    xiaoxiao2021-03-25  80

    /** * 短信倒计时 */ int time = 61; //倒计时初始时间 android.os.Handler handler = new android.os.Handler(); private void reverseTime() { handler.postDelayed(new Runnable() { @Override public void run() { time--; //倒计时按钮不可用 tvCheckcode.setEnabled(false); //倒计时字体颜色 tvCheckcode.setTextColor(Color.BLACK); //倒计时time秒 tvCheckcode.setText("剩余时间:" + time + "s)"); if (time >= 0) { handler.postDelayed(this, 1000); } else { //当倒计时为0秒时,恢复初始状态 time = 61; tvCheckcode.setText("获取验证码"); tvCheckcode.setEnabled(true); tvLoginCheckcode.setTextColor(Color.BLUE); } } }, 1000); }
    转载请注明原文地址: https://ju.6miu.com/read-33373.html

    最新回复(0)