小编Dan*_*iel的帖子

格式化倒数计时器,00:00:00无效.显示00:00:00直到暂停,然后显示剩余时间

我试图从http://helloandroidworld.com/2010/02/how-to-create-a-simple-android-countdown-timer/创建一个倒计时器,但是我无法使用我想要的格式00 :文章中描述的00:00.计时器将启动并允许我暂停它,它将运行两分钟,但你看不到它在运行.如果你暂停它,你可以看到剩余多少时间但你无法让它工作.没有格式化它工作正常并倒计时.有没有人有这个工作或知道如何解决它?我一直在搜索,找不到任何像这样的倒数计时器的格式化.任何帮助,将不胜感激.

  TextView timeDisplay;
  MyCount counter;
  int state = 0;
  int length = 120000;
  long startTime = 0;
  long currentTime = 0;
  long timeElapsed = 0;
  long timeRemaining = 0;
  long prevTimeRemaining = 0;
  Button control;

    public String formatTime(long millis) {
          String output = "00:00:00";
          long seconds = millis / 1000;
          long minutes = seconds / 60;
          long hours = minutes / 60;

          seconds = seconds % 60;
          minutes = minutes % 60;
          hours = hours % 60; …
Run Code Online (Sandbox Code Playgroud)

android

5
推荐指数
1
解决办法
9384
查看次数

标签 统计

android ×1