从。员额()或UI线程运行Android旋转prevents,网络呼叫相关 [英] Android rotation prevents from .post() or UI thread running, related to network call
问题描述
在我的应用程序,我无法在屏幕方向改变后编辑任何UI元素。
In my application, I cannot edit any UI elements after a screen orientation is changed.
-
在自定义FragmentActivity:
静态处理程序uiHandler;
Defined in FragmentActivity: static Handler uiHandler;
在拼命地跑在片段单独的线程:
Runned in Fragment in separate thread:
uiHandler.post(新的Runnable(){公共无效的run(){chcemhovoritback.setBackgroundColor(Color.MAGENTA);
}
}
uiHandler.post(new Runnable() { public void run() { chcemhovoritback.setBackgroundColor(Color.MAGENTA); } }
我在应用程序已经拼命地跑一个职位()
而我,如果我跑前方向改变了,没有问题。
I have runned one post() already in application and I if I run it before orientation changed, no problem.
推荐答案
在方向变化,该活动创建。以prevent这种情况的发生,添加以下到<活性GT;
在的AndroidManifest.xml
标记(我不知道为什么这不是默认行为):
When orientation changes, the activity is recreated. To prevent this from happening, add the following to the <activity>
tag in AndroidManifest.xml
(I wonder why it's not the default behavior):
<activity
...
android:configChanges="orientation|keyboardHidden|screenSize" >
这篇关于从。员额()或UI线程运行Android旋转prevents,网络呼叫相关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!