VerCodeTimer mVerCodeTimer=(Button) findViewById(R.id.login_get_ver_code);
private class VerCodeTimer extends CountDownTimer {
private int seconds;
private int interval;
//millisInFuture为你设置的此次倒计时的总时长,比如60秒就设置为60000
//countDownInterval为你设置的时间间隔,比如一般为1秒,根据需要自定义。
public VerCodeTimer(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
seconds = (int) (millisInFuture / 1000);
interval= (int) (countDownInterval/1000);
}
//每过你规定的时间间隔做的操作
@Override
public void onTick(long millisUntilFinished) {
getVerCodeButton.setText((seconds-interval) + "秒后重新获取");
}
//倒计时结束时做的操作↓↓
@Override
public void onFinish() {
getVerCodeButton.setTextSize(10);
getVerCodeButton.setText("重新获取验证码");
getVerCodeButton.setClickable(true);
getVerCodeButton.setBackgroundResource(R.drawable.login_get_ver_code_before_bg);
}
}
@Override
public void onBackPressed() {
if (mVerCodeTimer != null)
mVerCodeTimer.cancel();
super.onBackPressed();
}
getVerCodeButton.setTextSize(11); getVerCodeButton.setClickable(false); getVerCodeButton.setBackgroundResource(R.drawable.login_get_ver_code_ago_bg); mVerCodeTimer = new VerCodeTimer(60000, 1000); mVerCodeTimer.start();
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
android:useLevel="false">
<!-- 背景填充颜色值 -->
<solid android:color="#6c948b" />
<!-- radius值越大,越趋于圆形 -->
<corners android:radius="10dip" />
<!-- 圆角图像内部填充四周的大小 ,将会以此挤压内部布置的view -->
<padding
android:bottom="10dip"
android:left="10dip"
android:right="10dip"
android:top="10dip" />
</shape>
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
android:useLevel="false">
<!-- 背景填充颜色值 -->
<solid android:color="#509989" />
<!-- radius值越大,越趋于圆形 -->
<corners android:radius="10dip" />
<!-- 圆角图像内部填充四周的大小 ,将会以此挤压内部布置的view -->
<padding
android:bottom="10dip"
android:left="10dip"
android:right="10dip"
android:top="10dip" />
</shape>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有