Android update TextView in Thread and Runnable

后端 未结 4 484
栀梦
栀梦 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:32

    You cannot access UI elements from non-UI threads. Try surrounding the call to setText(...) with another Runnable and then look into the View.post(Runnable) method.

提交回复
热议问题