我有一个使用 ActionBarSherlock 的活动。现在我想在该操作栏中显示一个不确定的进度,并按照 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 的抽象类。
但是当我尝试加载该活动时,我收到以下错误:
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
为什么会发生此错误,即使我在调用 setContentView 之前请求了 WindowFeature?