欢迎来到 Android人的问与答 ,在这里提问或帮助他人解答。 Question2Answer的1.6.x和1.7.x版本的中文翻译包我修改更新:

Question2answer

如何使用中文语言包

Q2A 1.6.x - Chinese Simplified (简体中文)

Q2A 1.7.x - Chinese Simplified (简体中文)


国内服务器推荐 阿里云服务器
国外服务器推荐 DigitalOcean
VPN推荐 正版Green VPN
阿里云推荐码:ldvq50

Android “Only the original thread that created a view hierarchy can touch its views.”

0 喜欢 0 不喜欢
207 浏览
在非UI线程操作View了。
 
 
You have to move the portion of the background task that updates the ui onto the main thread. There is a simple piece of code for this:

runOnUiThread(new Runnable() {
     @Override
     public void run() {

//stuff that updates ui

    }
});
Documentation for Activity.runOnUiThread

Just nest this inside the method that is running in the background, then copy paste the code that implements any updates in the middle of the block. Include only the smallest amount of code possible, otherwise you start to defeat the purpose of the background thread.
最新提问 12月 31, 2014 分类:Android View | 用户: forlong401 (7,050 分)

登录 或者 注册 后回答这个问题。

...