(Android开发)异常错误:requestFeature() must be called before adding content

今天添加一个自定义弹出框一直报这个错误:

(Android开发)异常错误:requestFeature() must be called before adding content_第1张图片

我的代码是这样写的:

View viewShuoShuo = View.inflate(this, R.layout.apple_shuoshuo, null);
			AlertDialog dialogShuoShuo = new AlertDialog.Builder(this).create();
			
			dialogShuoShuo.setContentView(viewShuoShuo);
			dialogShuoShuo.show();
很简单的一个添加,把AlertDialog换成Dialog就没有问题,但是还是想用AlertDialog,试了很多方式,还是报这个错误,后来解决了, 由于dialogShuoShuo.show()之前调用了dialogShuoShuo.setContentView()了,正确的应该是dialogShuoShuo.show()之后调用dialogShuoShuo.setContentView(),两句换一下位置即可,迷茫了几个小时,原来这么解决!真让人蛋疼

你可能感兴趣的:(android,null,dialog)