286_实现计时器功能
2016-09-29 21:43
148 查看
实现计时器功能
runnable = new Runnable() {
@Override
public void run() {
if (timeLeft <= 0) {
tv_shengyushijian.removeCallbacks(runnable);
} else {
tv_shengyushijian.setText(calCountSecs(timeLeft));
timeLeft -= 1000;
if (timeLeft >= 0) {
tv_shengyushijian.postDelayed(this, 1000);
}
}
}
};
public static String calCountSecs(long time) {
int d = (int) (time / 1000 / 60 / 60 / 24);
int h = (int) (time / 1000 / 60 / 60 - d * 24);
int m = (int) ((time / 1000 / 60) - h * 60 - d * 24 * 60);
int s = (int) (time / 1000 - m * 60 - h * 60 * 60 - d * 24 * 60 * 60);
return String.format("%d天%02d小时%02d分%02d秒", d, h, m, s);
}
变成详细的 多少天多少小时
runnable = new Runnable() {
@Override
public void run() {
if (timeLeft <= 0) {
tv_shengyushijian.removeCallbacks(runnable);
} else {
tv_shengyushijian.setText(calCountSecs(timeLeft));
timeLeft -= 1000;
if (timeLeft >= 0) {
tv_shengyushijian.postDelayed(this, 1000);
}
}
}
};
public static String calCountSecs(long time) {
int d = (int) (time / 1000 / 60 / 60 / 24);
int h = (int) (time / 1000 / 60 / 60 - d * 24);
int m = (int) ((time / 1000 / 60) - h * 60 - d * 24 * 60);
int s = (int) (time / 1000 - m * 60 - h * 60 * 60 - d * 24 * 60 * 60);
return String.format("%d天%02d小时%02d分%02d秒", d, h, m, s);
}
变成详细的 多少天多少小时
相关文章推荐
- chronometer计时器实现暂停功能与初始值为0的功能
- 安卓中实现计时器的功能
- Unity 封装 倒计时(计时器,CountDownTimer),实现周期更新、技能冷却等功能
- JavaScript实现计时器,一个按钮实现开始和停止的功能
- Chronometer实现计时器的开始停止重置功能
- ASP.NET中使用计时器(Timer)来实现群发邮件等功能(转载)
- [置顶] Cocos2d-x实现计时器与定时器功能
- 利用多线程实现计时器Timer功能
- 关于安卓如何实现计时器chronometer的暂停和继续计时功能
- unity计时器功能的实现
- 计时器---倒计时功能的实现
- python实现简单的计时器功能函数
- Android 利用 RXJAVA interval 操作符 实现 计时器 功能
- iOS开发 - Swift使用GCD实现计时器功能
- JS实现钟表计时器功能
- jQuery实现倒计时功能 jQuery实现计时器功能
- 5.计时器实现计时功能
- jQuery实现简单的计时器功能实例分析
- Android 实现计时器功能