安卓开发——requestFeature() must be called before adding content

今天在学习安卓开发时,为了实现取消标题栏,便在onCreate()里加了句requestWindowFeature(Window.FEATURE_NO_TITLE);

如图

安卓开发——requestFeature() must be called before adding content_第1张图片

巴特,载到手机上时,却异常退出。logcat一直报错


真是百思不得其解,我明明就是before,并没有after呀。

后来百度得知是由于我用的是Google最新的开发工具,继承的是ActionBarActivity,改成继承Activity就完美解决了。

//取消标题栏

requesteWindowFeature(Window.FEATURE_NO_TITLE);

//取消状态栏

this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);


你可能感兴趣的:(安卓开发)