安卓按钮60秒获取一次验证码
2014-07-17 14:04
204 查看
这是封装好的60秒获取验证码工具类
import android.os.CountDownTimer;
import android.widget.Button;
public class TimerCount extends CountDownTimer{
private Button bnt;
public TimerCount(long millisInFuture, long countDownInterval, Button bnt) {
super(millisInFuture, countDownInterval);
this.bnt = bnt;
}
public TimerCount(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
// TODO Auto-generated constructor stub
}
@Override
public void onFinish() {
// TODO Auto-generated method stub
bnt.setClickable(true);
bnt.setText("获取验证码");
}
@Override
public void onTick(long arg0) {
// TODO Auto-generated method stub
bnt.setClickable(false);
bnt.setText(arg0 / 1000+"秒后重新获取");
}
}
调用方法:
TimerCount timer=new TimerCount(60000,1000,getCode);
timer.start();这样即可时间效果,简单实用。
import android.os.CountDownTimer;
import android.widget.Button;
public class TimerCount extends CountDownTimer{
private Button bnt;
public TimerCount(long millisInFuture, long countDownInterval, Button bnt) {
super(millisInFuture, countDownInterval);
this.bnt = bnt;
}
public TimerCount(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
// TODO Auto-generated constructor stub
}
@Override
public void onFinish() {
// TODO Auto-generated method stub
bnt.setClickable(true);
bnt.setText("获取验证码");
}
@Override
public void onTick(long arg0) {
// TODO Auto-generated method stub
bnt.setClickable(false);
bnt.setText(arg0 / 1000+"秒后重新获取");
}
}
调用方法:
TimerCount timer=new TimerCount(60000,1000,getCode);
timer.start();这样即可时间效果,简单实用。
相关文章推荐
- 对安卓获取验证码倒计时60秒Button按钮的简单封装
- Angular.js实现获取验证码倒计时60秒按钮的简单方法
- vue获取手机验证码60秒倒计时,不能点击按钮
- 【Android自定义View实战】之获取验证码倒计时按钮
- 【iOS】点击按钮获取验证码控件
- Android 实现点击按钮获取验证码 60秒后重新获取效果
- 获取验证码,60秒倒计时js
- 安卓发送验证码倒计时效果和自动获取验证码并填充到输入框
- android中获取验证码后出现60秒的倒计时
- 获取短信按钮倒计时60秒
- android (获取验证码)倒计时按钮或者TextView
- 点击读秒获取验证码按钮实现
- 安卓ContentObserver模式获取短信用正则自动填充验证码
- 获取验证码button,倒计时按钮,继承Button
- 获取验证码 60秒倒计时 setInterval
- 用户点击获取验证码之后我们会发送一条信息到用户手机,然后就会出现一个倒计时按钮,很像支付宝手机付款效果了,下面我给大家分享两个js效果
- 点击获取验证码按钮后按钮变灰,倒计时一段时间后又可重复点击
- 获取验证码之后出现一个倒计时按钮
- 安卓自动获取验证码(忘记密码为例)
- Android登陆页面,获取验证码按钮的实现