線程UI更新報錯:Only the original thread that created a view hierarchy can touch its views.

當我們在線程裏面更新UI的時候會報錯:Only the original thread that created a view hierarchy can touch its views. 如下面的代碼:直接在UDP發送線程裏面更新UI,就會報錯,報錯提示如下。 這裏的解決辦法是把UI更新放到Handler裏面。所以把上述代碼的UI更新部分修改爲如下圖所示。
相關文章
相關標籤/搜索