2

我知道这个问题已经在堆栈上被问过,但我尝试了所有解决方案但没有用。我仍然得到相同的错误

原因:android.util.AndroidRuntimeException:requestFeature() 必须在添加内容之前调用

下面是代码-

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        **requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);**  
        setContentView(R.layout.info);
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
     }

我尝试了许多链接,如下所示 - https://stackoverflow.com/search?q=requestFeature%28%29+must+be+call+before+adding+content

有什么解决办法???

4

2 回答 2

3

尝试这个

@Override
    protected void onCreate(Bundle savedInstanceState) {

        requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.info);

     }
于 2013-12-21T11:08:12.360 回答
1

你试过这个吗。。

@Override
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);  
    super.onCreate(savedInstanceState);   
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);     
    setContentView(R.layout.info);        
 }
于 2013-12-21T11:29:39.737 回答