Verification code countdown

tool
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);    
    }

}

Instructions

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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324852983&siteId=291194637