显示计时器在android系统 [英] Showing Timer in android

查看:113
本文介绍了显示计时器在android系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是我的屏幕上显示一个简单的定时器时钟它从20开始,并继续减少,当它变成0我想开始一个动作。
如何实现这一目标?
在此先感谢

My objective is to display a simple timer clock on my screen where it starts from 20 and goes on decreasing and when it becomes 0 I want to start an action. How to achieve this ? Thanks in advance

推荐答案

我不知道你是怎么想显示它,但你可以采取一个TextView做到这一点也并保留改变其每秒文本。

I don't know how you want to display it but you can do this also just by taking a TextView and keep changing its Text every second.

static int i = 20;
 new CountdownTimer(20000, 1000) {

     public void onTick(long millisUntilFinished) {
         i = i-1;
         mTextField.setText(String.valuOf(i));
     }

     public void onFinish() {
         //do your stuff here
     }
  }.start();

这篇关于显示计时器在android系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆