且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android-测量两次按钮单击之间的时间

更新时间:2023-02-05 20:44:06

第一次单击创建一个变量:

On the first click create a variable:

long startTime = System.currentTimeMillis();

然后在第二次单击上可以计算出差异:

Then on the second click you can calculate the difference:

long difference = System.currentTimeMillis() - startTime;

差异/1000 将为您提供差异(以秒为单位).希望这会有所帮助.

difference / 1000 will give you the difference in seconds. Hope this helps.