验证码倒计时

工具
public class CountDownTimeUtils extends CountDownTimer {
    private Button mButton;

    public CountDownTimeUtils(long millisInFuture, long countDownInterval,Button button) {
        super(millisInFuture, countDownInterval);
        mButton = button;
    }

    @Override
    public void onTick(long l) {
        mButton.setClickable(false);
        mButton.setText("重新发送"+l/1000+"s");
        mButton.setTextSize(14);
    }

    @Override
    public void onFinish() {
        mButton.setClickable(true);
        mButton.setText(R.string.get_validata_code);
    }

}

使用方法

mTimeUtils = new CountDownTimeUtils(1000*60L,1000,mGetValidataCodeButon);
mTimeUtils.start();

猜你喜欢

转载自blog.csdn.net/qq_34272093/article/details/80079096
今日推荐