关于requestFeature() must be called before adding content

想显示dialog时,如果想显示的是自定义布局的dialog,并使用如下方式,则会报错requestFeature() must be called before adding content

AlertDialog dlg = new AlertDialog.Builder(this).create();               
dlg.setContentView(R.layout.dialog_layout);  
dlg.show(); 

修改方法是,改变一下顺序,先dlg.show();然后再进行setContentView(R.layout.dialog_layout);就没问题了。

原文地址:https://www.cnblogs.com/wytings/p/4296410.html