How to set timer in android?

后端 未结 21 1250
渐次进展
渐次进展 2020-11-22 00:51

Can someone give a simple example of updating a textfield every second or so?

I want to make a flying ball and need to calculate/update the ball coordinates every se

21条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-22 01:28

    You want your UI updates to happen in the already-existent UI thread.

    The best way is to use a Handler that uses postDelayed to run a Runnable after a delay (each run schedules the next); clear the callback with removeCallbacks.

    You're already looking in the right place, so look at it again, perhaps clarify why that code sample isn't what you want. (See also the identical article at Updating the UI from a Timer).

提交回复
热议问题