RequestFeature() must be called before adding content

异常Log ,如下:


RequestFeature() must be called before adding content_第1张图片
Paste_Image.png

方法一:

将 ActionBarActivity和AppCompatActivity 替换为 Activity , onCreate中代码如下:

@Override 
protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState); 
 requestWindowFeature(Window.FEATURE_NO_TITLE);
 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
 setContentView(R.layout.activity_main);
}

方法二:

在 ActionBarActivity和AppCompatActivity中,onCreate代码如下:

@Override 
protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState); 
 supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
 setContentView(R.layout.activity_main);
}

NOTE: 关键就是 将 requestWindowFeature 替换为 supportRequestWindowFeature

你可能感兴趣的:(RequestFeature() must be called before adding content)