Android update TextView in Thread and Runnable

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

    As an option use runOnUiThread() to change de views properties in the main thread.

      runOnUiThread(new Runnable() {
            @Override
            public void run() {       
                    textView.setText("Stackoverflow is cool!");
            }
        });
    

提交回复
热议问题