runOnUiThread()是Activity类中的方法,它用于从子线程中切换到主线程来执行一些操作,比如更新UI。

new Thread(new Runnable() {
            @Override
             public void run() {
                //do something takes long time in the work-thread
                 runOnUiThread(new Runnable() {
                     @Override
                     public void run() {
                        textView.setText("test");
                     }
                 });
             }
         }).start();

 

查看定义发现,这个是通过handler来操作的。

runOnUiThread

 

参考:

https://www.cnblogs.com/andy-songwei/p/12064596.html

 

相关文章:

  • 2021-09-08
  • 2021-06-10
  • 2021-06-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-06
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-08
  • 2021-08-01
  • 2021-07-28
  • 2021-07-29
相关资源
相似解决方案