requestFeature() must be called before adding content错误

简介:

0-04 15:15:36.218: E/AndroidRuntime(5176): FATAL EXCEPTION: main
10-04 15:15:36.218: E/AndroidRuntime(5176): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.solar/com.solar.SetupInfoActivity}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
10-04 15:15:36.218: E/AndroidRuntime(5176): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
10-04 15:15:36.218: E/AndroidRuntime(5176): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
10-04 15:15:36.218: E/AndroidRuntime(5176): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-04 15:15:36.218: E/AndroidRuntime(5176): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
10-04 15:15:36.218: E/AndroidRuntime(5176): at android.os.Handler.dispatchMessage(Handler.java:99)
10-04 15:15:36.218: E/AndroidRuntime(5176): at android.os.Looper.loop(Looper.java:130)
10-04 15:15:36.218: E/AndroidRuntime(5176): at android.app.ActivityThread.main(ActivityThread.java:3683)
10-04 15:15:36.218: E/AndroidRuntime(5176): at java.lang.reflect.Method.invokeNative(Native Method)
10-04 15:15:36.218: E/AndroidRuntime(5176): at java.lang.reflect.Method.invoke(Method.java:507)
10-04 15:15:36.218: E/AndroidRuntime(5176): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-04 15:15:36.218: E/AndroidRuntime(5176): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-04 15:15:36.218: E/AndroidRuntime(5176): at dalvik.system.NativeStart.main(Native Method)
10-04 15:15:36.218: E/AndroidRuntime(5176): Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
10-04 15:15:36.218: E/AndroidRuntime(5176): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:181)
10-04 15:15:36.218: E/AndroidRuntime(5176): at android.app.Activity.requestWindowFeature(Activity.java:2729)
10-04 15:15:36.218: E/AndroidRuntime(5176): at com.solar.BaseActivity.onCreate(BaseActivity.java:20)
10-04 15:15:36.218: E/AndroidRuntime(5176): at com.solar.SetupInfoActivity.onCreate(SetupInfoActivity.java:53)
10-04 15:15:36.218: E/AndroidRuntime(5176): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-04 15:15:36.218: E/AndroidRuntime(5176): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
10-04 15:15:36.218: E/AndroidRuntime(5176): ... 11 more

  错误提示见红字部分

1     protected void onCreate(Bundle savedInstanceState) {
2         this.setContentView(R.layout.setup_info_page);
3         this.requestWindowFeature(Window.FEATURE_NO_TITLE);//           Activity去掉标题
4     super.onCreate(savedInstanceState);
5     }

       这里 this.setContentView(R.layout.setup_info_page)

this.requestWindowFeature(Window.FEATURE_NO_TITLE)方法调用更早,所以报错 了。

只需要保证setContentView方法在requestWindowFeature方法之后执行就可以了。


作者:kissazi2 
出处:http://www.cnblogs.com/kissazi2/ 
本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

转载:http://www.cnblogs.com/kissazi2/archive/2012/10/04/2711479.html

目录
相关文章
|
4月前
|
存储 缓存 自然语言处理
“error“: { “root_cause“: [{ “type“: “circuit_breaking_exception“, “reason“: “[parent] D【已解决】
“error“: { “root_cause“: [{ “type“: “circuit_breaking_exception“, “reason“: “[parent] D【已解决】
38 1
|
5月前
|
Android开发
Failed resolution of: Landroidx/localbroadcastmanager/content/LocalBroadcastManager
Failed resolution of: Landroidx/localbroadcastmanager/content/LocalBroadcastManager
64 0
|
应用服务中间件 Android开发
a configuration error occurred during startup. place verify the preference field whth the prompt:TomcatJDK name:
a configuration error occurred during startup. place verify the preference field whth the prompt:TomcatJDK name:
130 0
a configuration error occurred during startup. place verify the preference field whth the prompt:TomcatJDK name:
2015-03-18 - Deliberately pass a wrong note type for my task creation
2015-03-18 - Deliberately pass a wrong note type for my task creation
92 0
2015-03-18 - Deliberately pass a wrong note type for my task creation
A small tip to explore how to call a method of a control
Created by Jerry Wang, last modified on Mar 20, 2015
128 0
A small tip to explore how to call a method of a control
header note truncation issue - designed behavior
header note truncation issue - designed behavior
105 0
header note truncation issue - designed behavior
How to resolve warning message Access restriction -The type Resource is not accessible
How to resolve warning message Access restriction -The type Resource is not accessible
How to resolve warning message Access restriction -The type Resource is not accessible
Cannot find source code based button in SE24 - modification assistant
Cannot find source code based button in SE24 - modification assistant
156 0
|
Java Apache
Failed to place enough replicas
如果DataNode的dfs.datanode.data.dir全配置成SSD类型,则执行“hdfs dfs -put /etc/hosts hdfs:///tmp/”时会报如下错误: 2017-05-04 16:08:22,545 WARN org.
3280 0