0
点赞
收藏
分享

微信扫一扫

requestFeature() must be called before adding content 错误

路西法阁下 2022-03-30 阅读 59

public void onCreate(Bundle savedInstanceState) {

           super.onCreate(savedInstanceState);

           setContentView(R.layout.tab_choice);

     requestWindowFeature(Window.FEATURE_NO_TITLE);

}

public void onCreate(Bundle savedInstanceState) {

           super.onCreate(savedInstanceState);

           setContentView(R.layout.tab_choice);

     requestWindowFeature(Window.FEATURE_NO_TITLE);

}


0 2-17 10:31:38.792: E/AndroidRuntime(630): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hr/com.hr.tab_choice}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content

其中: setContentView(R.layout.tab_choice);

    requestWindowFeature(Window.FEATURE_NO_TITLE);

两行顺序换一下就可以了。

改后:

public void onCreate(Bundle savedInstanceState) {

           super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);

           setContentView(R.layout.tab_choice);

}


其中: setContentView(R.layout.tab_choice);

    requestWindowFeature(Window.FEATURE_NO_TITLE);

两行顺序换一下就可以了。

改后:

public void onCreate(Bundle savedInstanceState) {

           super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);

           setContentView(R.layout.tab_choice);

}


举报

相关推荐

【Calendar】before和after错误

0 条评论