.AndroidRuntimeException: requestFeature() must be called before adding content

有以下几种情况:

1.

        setContentView(R.layout.activity_list);
        requestWindowFeature(Window.FEATURE_NO_TITLE);

修改方法:

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_list);

 2.在dialog.show()方法前调用了dialog.setContentView()或者dialog.getWindow()

        dialog.setContentView(R.layout.activity_main);          //或者是调用了 dialog.getWindow();
        dialog.show();

 修改方法:

        dialog.show();
        dialog.setContentView(R.layout.activity_main);

 3. ***activity继承了ActionBarActivity,然后调用requestWindowFeature(Window.FEATURE_NO_TITLE);报异常

修改方法:使***activity继承自 Activity

 

posted @ 2016-10-20 14:38  初心。。。  阅读(176)  评论(0编辑  收藏  举报