[英]timer with 10milli second resolution android
我正在尝试显示格式为1.00的计数计时器。 基本上是秒,分辨率为百分之一秒或10ms。 我已经尝试过天文钟功能,但仍然没有运气,似乎它只能跟踪1秒的分辨率。 这是我的一些代码:
public void stopwatch() {
stopWatch.setOnChronometerTickListener(new OnChronometerTickListener(){
@Override
public void onChronometerTick(Chronometer arg0) {
countUpmilli = (Long) ((SystemClock.elapsedRealtime() -arg0.getBase())/ 100);
countUpSec = (Long) ((SystemClock.elapsedRealtime() -arg0.getBase()) / 1000);
//asText = (countUp / 60) + ":" + (countUp % 60);
asText = (countUpSec / 1) + "." + (countUpmilli%100);
timertext.setText(asText);
}
});
stopWatch.start();
}
我认为您必须使用System.nanoTime();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.