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

  错误提示见红字部分

错误的代码

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

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

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

本文转自陈哈哈博客园博客,原文链接http://www.cnblogs.com/kissazi2/archive/2012/10/04/2711479.html如需转载请自行联系原作者


kissazi2

相关文章
|
9月前
|
缓存 PHP
Composer 报错 Error while processing content unencoding: Unknown failure within ...
Composer 报错 Error while processing content unencoding: Unknown failure within ...
137 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:
106 0
a configuration error occurred during startup. place verify the preference field whth the prompt:TomcatJDK name:
A small tip to explore how to call a method of a control
Created by Jerry Wang, last modified on Mar 20, 2015
112 0
A small tip to explore how to call a method of a control
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
72 0
2015-03-18 - Deliberately pass a wrong note type for my task creation
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
117 0
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
128 0
How is target My note application rendered - renderManager
Created by Wang, Jerry, last modified on May 18, 2015
101 0
How is target My note application rendered - renderManager
OPA 11 - how is check called in my iClickTheCreateButton
Created by Wang, Jerry, last modified on Nov 08, 2015
125 0
OPA 11 - how is check called in my iClickTheCreateButton
How to find root cause of creation navigation failure
Created by Jerry Wang, last modified on Dec 09, 2014
How to find root cause of creation navigation failure