Android update TextView in Thread and Runnable

后端 未结 4 487
栀梦
栀梦 2020-11-27 14:18

I want to make a simple timer in Android that updates a TextView every second. It simply counts seconds like in Minesweeper.

The problem is when i ignore the tvTime.

4条回答
  •  被撕碎了的回忆
    2020-11-27 14:19

    Alternatively, you can also just do this in your thread whenever you want to update a UI element:

    runOnUiThread(new Runnable() {
        public void run() {
            // Update UI elements
        }
    });
    

提交回复
热议问题