我可以为代码B中的对话框设置setCancelable(false),现在我希望为代码A中的Anko对话框设置相同的属性。
我该怎么办?谢谢!
代码A
private fun deleteBackup(){
alert(getString(R.string.DialogDeleteContent), getString(R.string.DialogDeleteTitle)) {
yesButton {
//...
}
}.show()
}
代码B
private fun promptBuyWhenExpired() {
if (IsExpired(applicationContext) ) {
val builder = AlertDialog.Builder(this)
builder.setMessage(getString(R.string.ExpiredTitle))
builder.setTitle(getString(R.string.ExpiredWarning))
builder.setCancelable(false)
builder.setPositiveButton(getString(R.string.BtnYes)) { dialog, which ->
finish()
}
builder.create().show()
}
}
答案:
我明白了,它应该是.show()。setCancelable(false)
答案 0 :(得分:1)
alert("message", "title") {
yesButton {
//...
}
isCancelable = false
}.show()