重新发送验证码
2016-07-13 14:39
381 查看
package com.example.countdowntimer; import android.os.Bundle; import android.os.CountDownTimer; import android.app.Activity; import android.graphics.Color; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class MainActivity extends Activity { private TimeCount time; private Button btnGetcode; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); time = new TimeCount(60000, 1000); btnGetcode=(Button) findViewById(R.id.btn_getcode); btnGetcode.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { time.start(); } }); } class TimeCount extends CountDownTimer { public TimeCount(long millisInFuture, long countDownInterval) { super(millisInFuture, countDownInterval); } @Override public void onTick(long millisUntilFinished) { btnGetcode.setBackgroundColor(Color.parseColor("#B6B6D8")); btnGetcode.setClickable(false); btnGetcode.setText("("+millisUntilFinished / 1000 +") 秒后可重新发送"); } @Override public void onFinish() { btnGetcode.setText("重新获取验证码"); btnGetcode.setClickable(true); btnGetcode.setBackgroundColor(Color.parseColor("#4EB84A")); } } }
相关文章推荐
- javassist 基本用法
- 网站缓存技术总结( ehcache、memcache、redis对比)
- JAVA日期工具类
- java swing餐厅点餐系统的设计与实现及源码之Java图形界面餐厅点餐系统的实现
- 区块链在中国(1):IBM HyperLedger
- [SSIS] 在脚本里面使用数据库连接字符串进行查询等处理, 入坑
- NS2在Ubuntu14.04下使用时执行nam遇到Segment Fault (core dump)的解决方法
- LeetCode integer to Roman详解
- 欢迎使用CSDN-markdown编辑器
- 可重入函数与线程安全的区别及联系
- What is zero-shot learning?
- UESTC621 吴神的大脑
- 第六章 ASP.NET应用实例 -- 学习笔记
- C源程序到可执行文件的步骤
- 同一个textview设置不同文字样式
- LayoutAnimation
- iOS开发支付集成之支付宝支付
- css选择器大全
- 各大组织大马默认密码
- Google 的开源技术protobuf 简介与例子