想用1秒的延迟显示号码 [英] Want to display number with 1sec delay

查看:167
本文介绍了想用1秒的延迟显示号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在这样一个TextView显示数字:

I want to display numbers in a TextView like this:

Wait 5 sec // then a delay of 1 sec
Wait 4 sec // display this in the same text view along with delay
Wait 3 sec // display this in the same text view along with delay
Wait 2 sec // display this in the same text view along with delay
Wait 1 sec // display this in the same text view along with delay

我想执行一个按钮点击这个动作,它应该像一个倒计时器。

I want perform this action on a button click and it should work like a count down timer.

推荐答案

您可以使用这一个

new CountDownTimer(30000, 1000) {

     public void onTick(long millisUntilFinished) {
         mTextField.setText("Wait: " + millisUntilFinished / 1000);
     }

     public void onFinish() {
         mTextField.setText("done!");
     }
  }.start();

这Timer类可以在开始按钮点击的时候,你也可以调整总时间和刻度间隔

This timer class can start at the time of button click and also you can adjust the total time and the tick interval

这是从开发网站

这篇关于想用1秒的延迟显示号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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