码迷,mamicode.com
首页 > 其他好文 > 详细

requestFeature() must be called before adding content

时间:2015-10-11 19:38:00      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:

11-06 07:09:07.638  24338-24338/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.RuntimeException: Unable to start activity ComponentInfo{jukay.com.myapplication/jukay.com.myapplication.MainActivity}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2233)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2283)
            at android.app.ActivityThread.access$600(ActivityThread.java:147)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1262)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:5160)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:525)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
            at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:227)
            at android.app.Activity.requestWindowFeature(Activity.java:3264)
            at jukay.com.myapplication.MainActivity.onCreate(MainActivity.java:19)
            at android.app.Activity.performCreate(Activity.java:5133)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2283)
            at android.app.ActivityThread.access$600(ActivityThread.java:147)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1262)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:5160)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:525)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
            at dalvik.system.NativeStart.main(Native Method)

  出现这样的错误,网上大多数说是下面的代码写反了

requestWindowFeature(Window.FEATURE_NO_TITLE);// 隐藏了标题栏

        setContentView(R.layout.activity_main);

事实上代码没有写反的时候也有可能出现这样的问题,技术分享

如果是继承Activity就没有问题

技术分享

requestFeature() must be called before adding content

标签:

原文地址:http://www.cnblogs.com/shuimojun/p/4869705.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!