Android Handler Periodically

前端 未结 3 731
清歌不尽
清歌不尽 2021-01-12 15:22

This I want I want to achieve:

  1. An activity starts with no ClickListener and has four textviews all with white background

  2. I want to change th

3条回答
  •  时光取名叫无心
    2021-01-12 15:32

    There is no need to create a thread for this, or animations.

    The solution is really simple: use Handler.postDelayed() or Handler.sendMessageDelayed():

    http://developer.android.com/reference/android/os/Handler.html#postDelayed(java.lang.Runnable, long) http://developer.android.com/reference/android/os/Handler.html#sendMessageDelayed(android.os.Message, long)

    For a robust implementation, be sure to remove any pending messages at least by Activity.onDestroy(). (Or if you are posting them in Activity.onStart(), remove them in Activity.onStop(); if posting in Activity.onResume(), remove in Activity.onPause().)

提交回复
热议问题