2013-02-09 31 views

回答

0

http://developer.android.com/reference/android/widget/Chronometer.html

对于设定的基准时间,你可以使用elapsedRealtime(),你可以用setFormat()

+0

以及如何使用它?我试过crono.setBase(SystemClock.elapsedRealtime(60000));但它不起作用 – Katherine99 2013-02-09 13:01:50

+0

你可以看看实现比比尔莫特后:http://stackoverflow.com/questions/526524/android-get-time-of-chronometer-widget – jackgris 2013-02-09 13:12:00

1

一般的计时表是这样的(如果你想设置的基本输出格式到一个特定的NR):

mChronometer.setBase(SystemClock.elapsedRealtime() - (nr_of_min * 60000 + nr_of_sec * 1000)))

你问可通过倒计时(http://developer.android.com/reference/android/os/CountDownTimer.html

或通过使用像这样的(更多的工作应该做的,因为我只写了这一点,并没有测试它尚未)

记时计创建自己的倒计时完成
private OnChronometerTickListener countUp = new OnChronometerTickListener(){ 
@Override 
public void onChronometerTick(Chronometer chronometer){ 
      long elapsedTime = (SystemClock.elapsedRealtime() - mChronometerCountUp.getBase())/60000; 
      Log.v("counting up", elapsedTime); 
      // you will see the time counting up 
      count_down--; 
       if(count_down == 0){ 
       mChronometerCountUp.stop(); 
      } 
      // an int which will count down, 
      // this is not (very) accurate due to the fact that u r using the update part of the chronometer 
      // u just might implement the countdown i guess 
      // or 2 chronometers (one counting up and an other counting down using the elapsed time :p) 
      // just remember programming is creating ur solution to problems u face its like expression urself 
     }; 
    }; 
相关问题