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();
  • 相关阅读:
    Map集合的四种遍历
    java 请求 google translate
    Linux 内核初级管理
    Linux GRUB
    Linux 系统启动流程
    Linux 任务计划 crontab
    Linux 进程管理工具
    Linux sudo实作
    Linux 进程管理
    Linux 网络配置命令:ip、ss
  • 原文地址:https://www.cnblogs.com/matd/p/12855826.html
Copyright © 2011-2022 走看看