android开发 bug问题解决:Only the original thread that created a view hierarchy can touch its views
生活随笔
收集整理的這篇文章主要介紹了
android开发 bug问题解决:Only the original thread that created a view hierarchy can touch its views
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
android開發(fā) bug問題解決:Only the original thread that created a view hierarchy can touch its views.
翻譯:只有創(chuàng)建視圖層次結(jié)構(gòu)的原始線程才能觸及其視圖。(意思就是在異步線程中不能更新主線程UI)
解決辦法之一
創(chuàng)建一個handler去更新UI線程
代碼實現(xiàn)
1、handler處理返回數(shù)據(jù)請求,并更新數(shù)據(jù)到UI線程中
2、在異步線程接收處理中,調(diào)用handler發(fā)送需要更改的數(shù)據(jù)
public void sendMsg(String msg) {Log.e(TAG, "得到的信息:" + msg);Message message = new Message();message.obj = msg;myHandler.sendMessage(message);}問題解決
總結(jié)
以上是生活随笔為你收集整理的android开发 bug问题解决:Only the original thread that created a view hierarchy can touch its views的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 关于补码的详解
- 下一篇: Android开发 Intent传递参