安卓定时器摆动 [英] android timer swing

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

问题描述

我需要创建一个计时器来定期更新 UI.但是 Swing Timer 类在 Android 上不可用.我怎样才能解决这个问题?(我会避免创建线程,然后使用 java.util 包中的 Timer 类)

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)

推荐答案

您可以使用 HandlerpostAtTime() 方法postDelayed() 方法.这将允许您安排一个 Runnable 在未来的某个时间点执行.

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.

这篇关于安卓定时器摆动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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