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

相关文章
|
8月前
|
缓存 PHP
Composer 报错 Error while processing content unencoding: Unknown failure within ...
Composer 报错 Error while processing content unencoding: Unknown failure within ...
129 0
|
1月前
|
安全 Java 应用服务中间件
A configuration error occurred during startup.Please verify the preference field with the prompt: To
A configuration error occurred during startup.Please verify the preference field with the prompt: To
12 0
|
4月前
|
JavaScript
Uncaught runtime errors: × ERROR Avoided redundant navigation to current location: “/xxx“.
Uncaught runtime errors: × ERROR Avoided redundant navigation to current location: “/xxx“.
60 0
报错解决:Reason: Failed to determine a suitable driver class
报错解决:Reason: Failed to determine a suitable driver class
2452 0
报错解决:Reason: Failed to determine a suitable driver class
|
应用服务中间件 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
header note truncation issue - designed behavior
header note truncation issue - designed behavior
85 0
header note truncation issue - designed behavior
如何处理错误消息Unable to install breakpoint due to missing line number attributes
如何处理错误消息Unable to install breakpoint due to missing line number attributes
158 0
如何处理错误消息Unable to install breakpoint due to missing line number attributes
the code place where the binding is converted to final value displayed in u
the code place where the binding is converted to final value displayed in u
102 0
the code place where the binding is converted to final value displayed in u
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