我有一个包含10和20个问题的游戏。我需要计算用户完成游戏所用的时间。
我使用这个来停止计数器:
现在我需要两件事情:
Timer T=new Timer();
T.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
runOnUiThread(new Runnable()
{
public void run()
{
countdown.setText(""+count);
count++;
}
});
}
}, 1000, 1000);
我使用这个来停止计数器:
T.cancel();
现在我需要两件事情:
- 一种计算经过时间并将其存储在变量中的方法
- 我需要最终值是一个双精度浮点数,例如最终得分为:15.49秒。