android.util.AndroidRuntimeException: requestFeature() must be called before adding content 错误解决方法

Activity全屏,网上的代码如下:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//去掉信息栏
    setContentView(R.layout.activity_main);
} 但在AS中,会提示错误:
android.util.AndroidRuntimeException: requestFeature() must be called before adding content
解决如下:
protected void onCreate(Bundle savedInstanceState) {
this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//去掉信息栏
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
上一篇:ZOJ 1007 Numerical Summation of a Series


下一篇:Linux使用有线上网教程