错误:" requestFeature()必须添加内容和QUOT之前被调用;,虽然它的setContentView之前称为() [英] Error: "requestFeature() must be called before adding content", although it is called before setContentView()
问题描述
我有一个活动,它使用了ActionBarSherlock。现在,我想在动作条显示一个不确定的进度,并遵循从ActionBarSherlock的例子:
I have an Activity which uses the ActionBarSherlock. Now I wanted to show an Indeterminate Progress in that actionbar and followed the example from ActionBarSherlock:
public class MainMenu extends SimpleWebActivity implements BackgroundBrowserReciever {
private Boolean windowFeatureCalled;
@Override
public void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
super.onCreate(savedInstanceState);
this.windowFeatureCalled = true;
setContentView(R.layout.main_menu);
....
}
的SimpleWebActivity是延伸一个SherlockActivity的抽象类。
The SimpleWebActivity is an abstract class which extends a SherlockActivity.
但是,当我尝试加载的活动,我得到以下错误:
But when I try to load that Activity, I get the following error:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dalthed.tucan/com.dalthed.tucan.ui.MainMenu}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
为什么这个错误发生,甚至当我要求WindowFeature调用的setContentView之前?
Why does this error occur, even when i request that WindowFeature before calling setContentView?
推荐答案
您Super.onCreate后移动它,这应该解决您的问题。
Move it after your Super.onCreate, that should resolve your issue.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//HERE
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.main_menu);
this.windowFeatureCalled = true;
....
}
这篇关于错误:" requestFeature()必须添加内容和QUOT之前被调用;,虽然它的setContentView之前称为()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!