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方法之后执行就可以了。

你可能感兴趣的:(request)