错误:添加内容之前必须先调用requestFeature() [英] Error : requestFeature() must be called before adding content
本文介绍了错误:添加内容之前必须先调用requestFeature()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
原因:android.util.AndroidRuntimeException:必须在添加内容之前调用requestFeature()
这是我的代码,
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_SWIPE_TO_DISMISS);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
}}
推荐答案
好吧,只要执行错误消息告诉您的内容即可.
Well, just do what the error message tells you.
请勿在requestFeature()之前调用setContentView().
Don't call setContentView() before requestFeature().
注意:
正如评论中所述,对于ActionBarSherlock库和AppCompat库,都必须在super.onCreate()之前调用requestFeature()
As said in comments, for both ActionBarSherlock and AppCompat library, it's necessary to call requestFeature() before super.onCreate()
这篇关于错误:添加内容之前必须先调用requestFeature()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文