Android requestFeature() must be called before adding content报错
来源:互联网 发布:舵手医药软件 编辑:程序博客网 时间:2024/06/05 02:19
在Activity设置窗口没标题时用下面代码时报错:requestFeature() must be called before adding content
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); }
这是由于初始化时执行requestWindowFeature(Window.FEATURE_NO_TITLE)时需要在添加内容之前,网上的一些解决方案如下:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_main); //setContentView必须放在requestWindowFeature和getWindow().setFlags()中间 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); }
OK,点击调试运行....结果依然报这个错,试一下把requestWindowFeature(Window.FEATURE_NO_TITLE)放在super.onCreate前面,问题解决,最终代码是这样的:
protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); }
0 0
- Android requestFeature() must be called before adding content报错
- android 应用requestFeature() must be called before adding content报错
- requestFeature() must be called before adding content
- requestFeature() must be called before adding content
- requestFeature() must be called before adding content
- requestFeature() must be called before adding content
- requestFeature() must be called before adding content
- requestFeature() must be called before adding content
- requestFeature() must be called before adding content
- requestFeature() must be called before adding content
- android异常信息:requestFeature() must be called before adding content
- 【遇见Android bug】requestFeature() must be called before adding content
- android.util.AndroidRuntimeException: requestFeature() must be called before adding content
- android.util.AndroidRuntimeException: requestFeature() must be called before adding content
- Android requestFeature() must be called before adding content错误
- android.util.AndroidRuntimeException: requestFeature() must be called before adding content
- android.util.AndroidRuntimeException: requestFeature() must be called before adding content
- android.util.AndroidRuntimeException: requestFeature() must be called before adding content
- Classes, Objects, and Methods
- dom4j-----解析xml工具类
- 代码管理Git-忽略指定文件
- WIFI基本知识整理
- 基本数据类型对象包装类
- Android requestFeature() must be called before adding content报错
- 修改ArcMap默认的鼠标滚轮放大缩小,AE实现修改鼠标滚轮放大缩小
- eclipse搭建android开发环境搭建时遇见的问题
- 第一篇博文---OCM考试经验---监听
- 出现Font from origin处理方法 浏览器拦截跨域请求处理方法
- Linux上传下载文件命令
- 宽基线和窄基线
- 字符串常见笔试题
- listview中显示两种不同的item