安卓:记时计与毫秒? [英] Android: Chronometer with Miliseconds?

查看:500
本文介绍了安卓:记时计与毫秒?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要的是测量时间与毫秒为单位,但使用天文台都有它没有精确度的问题(其最分辨率为秒) 我已经看到了这一点: 显示毫秒与Android天文台 但我没有能够使它发挥作用。也许我应该用另外一个对象?你知道吗?

What I want is to measure time with miliseconds, but using Chronometer has the problem that it has no accuracy (its most resolution is seconds) I've seen this: Show miliseconds with Android Chronometer But I haven't been able to make it work. Maybe I should use another Object? Any idea?

推荐答案

好吧,这是最简单的方法:当你要开始计时:

Ok, this is the easiest way: When you want to start the chrono:

StartTime=System.currentTimeMillis(); // I've defined StartTime as a double

然后,你只需要做当前时间与开始时间比较:

Then, you just have to do compare current time with StartTime:

millis=System.currentTimeMillis()-StartTime; // Millis is a double too
// If you'd want seconds, add seconds=(int) milis/1000; etc.

和这样你就可以milis(它是否到达我想要的时间?这是多少计时?...)

And so you can play with milis (Has it arrive to the time I wanted? How many time is it counting? ...)

这篇关于安卓:记时计与毫秒?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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