Android - dialog 報錯 requestFeature() must be called before adding content

showDialog requestFeature() must be called before adding content

出现此问题是由于dialog.show()之前调用了dialog.setContentView()或者dialog.getwindow()等,正确的应该是dialog.show()之后调用dialog.setContentView()

dataPickerDialog.show() //要放最前面
dataPickerDialog.changeTitleStyle()
dataPickerDialog.changeDividerColor()