runOnUiThread in fragment

前端 未结 6 575
囚心锁ツ
囚心锁ツ 2020-11-30 21:49

I\'m trying to convert an Activity to fragment. The error mark on runOnUiThread. on the past:

GoogleActivityV2 extends from Activity. ru

6条回答
  •  旧时难觅i
    2020-11-30 22:20

    You can also post runnable using the view from any other thread. But be sure that the view is not null:

     tView.post(new Runnable() {
                        @Override
                        public void run() {
                            tView.setText("Success");
                        }
                    });
    

    According to the Documentation:

    "boolean post (Runnable action) Causes the Runnable to be added to the message queue. The runnable will be run on the user interface thread."

提交回复
热议问题