Android showDialog时报错requestFeature() must be called before adding content
时间:2016-03-03 14:45:09
收藏:0
阅读:2140
View view = View.inflate(this, R.layout.layout_dialog, null); AlertDialog alertDialog = new AlertDialog.Builder(TabActivity.this, R.style.CustomDialog).create(); alertDialog.setContentView(view); alertDialog.show(); alertDialog.setCanceledOnTouchOutside(true); alertDialog.setCancelable(true);
运行上面的代码报错:
原因:
于dialog.show()之前调用了dialog.setContentView()或者dialog.getwindow()等,正确的应该是dialog.show()之后调用dialog.setContentView()
评论(0)