zoukankan      html  css  js  c++  java
  • 验证码定时器

    CountDownTimerUtils
    public class CountDownTimerUtils extends CountDownTimer {
    
        private TextView mTextView;
    
        public CountDownTimerUtils(TextView textView, long millisInFuture, long countDownInterval) {
            super(millisInFuture, countDownInterval);
            this.mTextView = textView;
        }
    
        @Override
        public void onTick(long millisUntilFinished) {
            mTextView.setClickable(false);
            mTextView.setText(millisUntilFinished / 1000 + "秒");
            mTextView.setBackgroundColor(Color.parseColor("#cccccc"));
    
            SpannableString spannableString = new SpannableString(mTextView.getText().toString());
            ForegroundColorSpan span = new ForegroundColorSpan(Color.RED);
            spannableString.setSpan(span, 0, 2, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
            mTextView.setText(spannableString);
        }
    
        @Override
        public void onFinish() {
            mTextView.setText("获取验证码");
            mTextView.setClickable(true);
            mTextView.setBackgroundColor(Color.parseColor("#FF4081"));
        }

    使用

    CountDownTimerUtils mCountDownTimerUtils = new CountDownTimerUtils(tvCode, 60000, 1000);
                    mCountDownTimerUtils.start();
  • 相关阅读:
    Codeforces Round #274 (Div. 2)
    codeforces 477C
    ZOJ 3822 Domination
    Codeforces Round #271 (Div. 2)
    进程
    线程
    udp和tcp特点 实现文件上传
    面向对象补1
    socket基本语法和粘包
    网络编程
  • 原文地址:https://www.cnblogs.com/matd/p/12855826.html
Copyright © 2011-2022 走看看