短信验证码的计时功能

private CountDownTimer timer = new CountDownTimer(60000, 1000) {
@Override
public void onTick(long millisUntlFinished) {
tvPhoneCode.setText("已发送(" + millisUntlFinished / 1000 + "s)");
layPhoneCode.setEnabled(false);
tvPhoneCode.setTextColor(getResources().getColor(R.color.grey_600));
}

        @Override
        public void onFinish() {
            layPhoneCode.setEnabled(true);
            tvPhoneCode.setText(getResources().getString(R.string.to_obtain));
            tvPhoneCode.setTextColor(getResources().getColor(R.color.white));
        }
    };

    timer.start();




    就这样
    努力让世界变得更好
                           ------ geaosu

你可能感兴趣的:(短信验证码的计时功能)