显示倒计时的Button按钮
package com.pingyijinren.helloworld.activity; import android.os.CountDownTimer;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import com.pingyijinren.helloworld.R; public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private Button button;
private TimeCount timeCount; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = (Button) findViewById(R.id.button);
button.setOnClickListener(this); timeCount=new TimeCount(60000,1000);
} @Override
public void onClick(View v) {
timeCount.start();
} private class TimeCount extends CountDownTimer {
/**
* @param millisInFuture The number of millis in the future from the call
* to {@link #start()} until the countdown is done and {@link #onFinish()}
* is called.
* @param countDownInterval The interval along the way to receive
* {@link #onTick(long)} callbacks.
*/
public TimeCount(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
} @Override
public void onTick(long millisUntilFinished) {
button.setEnabled(false);
button.setText(millisUntilFinished/1000+"秒");
} @Override
public void onFinish() {
button.setEnabled(true);
button.setText("重新获取");
}
}
}
显示倒计时的Button按钮的更多相关文章
- 遭遇input与button按钮背景图失效不显示的解决办法
笔者从事网页前端代码页面工程师已有多年,作为一个网页重构人员常常会遇到一些莫名其妙的DIV+CSS(正确的说法是XHTML+CSS)在 IE.FireFox火狐. 谷歌浏览器CHROME.苹果浏览器S ...
- iphone中button按钮显示为圆形解决
iphone中button按钮显示为圆形解决: 添加样式: -webkit-appearance:button; 如果需要为直角: border-radius:0 在源码中添加如:style=&quo ...
- Android 自定义Button按钮显示样式(正常、按下、获取焦点)
现在的用户对APP的外观看得很重要,如果APP内所有元件都用Android默认样式写,估计下面评论里就有一堆在骂UI丑的.今天学习自定义Button按钮样式.Button样式修改的是Button的背景 ...
- input与button按钮背景图失效不显示的解决办法
今天做公司的某个网站前端网页页面的时候笔者又遇到了难解决的网页前端DIVCSS代码问题,一个平时不会发生的怪事情发生了:为网页代码中的Form表单中的input 和 button 按钮标签在CSS样式 ...
- Android实战简易教程-第四十一枪(显示倒计时的Button-适用于获取验证码)
近期在做获取验证码的功能.考虑到优良的用户体验,决定制作一个拥有倒计时提示的Button按钮,在网上查了一些资料,非常是简单的就能实现.我写了一个小Demo,大家能够应用到自己的项目中. 一.代码 1 ...
- RFS_点击button按钮之后,RFS出现卡死的问题
[html代码] <html> <head> <title> 主窗口 </title> </head> <body> <d ...
- 点击datalist中Button按钮出现“回发或回调参数无效......”
遇到问题: 回发或回调参数无效.在配置中使用 <pages enableEventValidation="true"/> 或在页面中使用 <%@ Page ...
- android中在java代码中设置Button按钮的背景颜色
android中在java代码中设置Button按钮的背景颜色 1.设置背景图片,图片来源于drawable: flightInfoPanel.setBackgroundDrawable(getRes ...
- Android学习笔记-Button(按钮)
Button是TextView的子类,所以TextView上很多属性也可以应用到Button 上!我们实际开发中对于Button的,无非是对按钮的几个状态做相应的操作,比如:按钮按下的时候 用一种颜色 ...
随机推荐
- sass 常用用法笔记
最近公司开发的h5项目,需要用到sass,所以领导推荐让我去阮一峰大神的SASS用法指南博客学习,为方便以后自己使用,所以在此记录. 一.代码的重用 1.继承:SASS允许一个选择器,继承另一个选择器 ...
- qt read excel
void exceladapter::readfile(QString filename, QString sheetname, int colNo){ QSqlDatabase db = QSqlD ...
- Really simple SSH proxy (SOCKS5)
原文: https://thomashunter.name/blog/really-simple-ssh-proxy-socks5/ SOCKS5 is a simple, eloquent meth ...
- laravel关联用户
参考文档:模型关联-反向关联 belongsToor 模型层 app/Post.php public function user() { return $this->belongsTo('\Ap ...
- Mac OSX简单使用中会用到的
选择操作系统(例如选择BootCamp分区的Windows):开机按住Option键直到磁盘图标出现后选择. 忘记本地账号密码:按着Command+R开机选择Recovered启动打开终端输入re ...
- (一) Docker in Docker
一. 背景介绍 工作中,要实现在docker中运行docker,实现镜像的拉取,创建,修改,上传等操作. 尝试过在docker中,安装docker.行不通,服务起不来. 而且直接在 docker 容 ...
- mysql利用binlog恢复数据
需求:需要给开发提供一个2018年9月30号的数据,按照我们公司正常备份策略来说,直接找到对应时间的备份数据,解压导入即可,恰好这个时间节点的数据没有,只备份到2018年9月25号的,糟糕了吧 咋办呢 ...
- && (and)、||(or) 条件语句
当前面条件满足时,就执行后面的代码 //条件为真时,就执行其中的语句 if($a>0){ $b='This is test'; } //上面的写法太麻烦,可以这样简写 $a>0 & ...
- No-5.远程管理常用命令
远程管理常用命令 目标 关机/重启 shutdown 查看或配置网卡信息 ifconfig ping 远程登录和复制文件 ssh scp 01. 关机/重启 序号 命令 对应英文 作用 01 shut ...
- HTML页面中解决内容元素随窗口变化布局变乱问题
1.给body加上一个min-width最小宽度,以px为单位,这样当页面变小时,当达到你所设置的最小宽度,body的宽度不再改变,超出的部分会用横向滚动条显示,其内所有元素的布局也不会受影响. 2. ...