Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
您可以使用 Timer 来安排重复的 TimerTask.每次您想要更新 UI 时,您都可以发布到 Handler您之前在 UI 线程中创建的。
TimerTask.每次您想要更新 UI 时,您都可以发布到 Handler您之前在 UI 线程中创建的。
只需记住在 onPause 中取消您的Timer,并在 onResume 中创建一个新的Timer 。
onPause
取消
Timer
onResume
You can use a Timer to schedule a repeating TimerTask. Each time you wanted to update the UI, you can post to a Handler that you previously created in the UI thread.
TimerTask
Just remember to cancel your Timer in onPause and create a new Timer in onResume.
cancel
还可以考虑将 AsyncTask 与计时器一起使用。这样你就不用担心处理程序了
Also consider using an AsyncTask with a Timer. You don't have to worry about handlers this way
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(2)
您可以使用 Timer 来安排重复的
TimerTask.每次您想要更新 UI 时,您都可以发布到 Handler您之前在 UI 线程中创建的。
只需记住在
onPause
中取消
您的Timer
,并在onResume
中创建一个新的Timer
。You can use a Timer to schedule a repeating
TimerTask
. Each time you wanted to update the UI, you can post to a Handler that you previously created in the UI thread.Just remember to
cancel
yourTimer
inonPause
and create a newTimer
inonResume
.还可以考虑将 AsyncTask 与计时器一起使用。这样你就不用担心处理程序了
Also consider using an AsyncTask with a Timer. You don't have to worry about handlers this way