android timer swing

回眸只為那壹抹淺笑 提交于 2019-12-24 01:24:56

问题


I need to create a Timer to update the UI at regular intervals. But the Swing Timer class is not available on Android. How can I work around this problem ? (I would avoid creating threads and then use the Timer class from java.util package)


回答1:


You could use a Handler and the postAtTime() method or the postDelayed() method. This will allow you to schedule a Runnable to be executed at some point in the future.




回答2:


Well, for your problem Handler class would suffice(+1 to Dave :)).
FYI, there are other classes namely AlarmManager, Timer & TimerTask that can help with timing the runs of your code.



来源:https://stackoverflow.com/questions/2005656/android-timer-swing

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!