作者:广药中山校区艺术团啦啦队 | 来源:互联网 | 2022-12-10 12:49
例如,我有下一个警报创建方式:
alert(message, title) {
positiveButton(R.string.alert_dialog_btn_ok) {
}
}.show()
我想将正面按钮的颜色更改为绿色,并在将来设置红色负面按钮.
如果不在警报内创建自定义DSL视图,我可以这样做吗?
1> 小智..:
alert("message", "title") {
positiveButton("ok") {}
negativeButton("nope") {}
}.show().apply {
getButton(AlertDialog.BUTTON_POSITIVE)?.let { it.textColor = Color.GREEN }
getButton(AlertDialog.BUTTON_NEGATIVE)?.let { it.textColor = Color.RED }
}
getButton()似乎不再存在。我得到“未解决的参考”。