属性动画实现短信验证码倒计时

来源:互联网 发布:开源c语言编译器哪个好 编辑:程序博客网 时间:2024/05/29 08:44
case R.id.tv_get_msgcode:    String account = mEdAccount.getText().toString().trim();    if (TextUtils.isEmpty(account) || !AMUtils.isMobile(account)) {        BlockedProgressDialog.dismissProgress();        MessageHelper.showInfo(mContext, mContext.getResources().getString(R.string.error_account));        break;    }    if (isMsgCoding) {        break;    }    isMsgCoding = true;    ValueAnimator valueAnimator = ValueAnimator.ofInt(60, 0);    valueAnimator.setDuration(1000*60);    valueAnimator.setInterpolator(new LinearInterpolator());    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {        @Override        public void onAnimationUpdate(ValueAnimator animation) {            Integer value = (Integer) animation.getAnimatedValue();            if (value == 0) {                mTvGetMsgCode.setText(getResources().getString(R.string.get_msg_again));                isMsgCoding = false;                mTvGetMsgCode.setTextColor(getResources().getColor(android.R.color.black));            } else {                mTvGetMsgCode.setText(getResources().getString(R.string.get_msg_again) + "(" + value + ")");                mTvGetMsgCode.setTextColor(getResources().getColor(R.color.text_no_focus));            }        }    });    valueAnimator.start();

原创粉丝点击