Kotlin / Anko防止按钮关闭警报对话框

当在Anko的警报构建器中使用positiveButtonnegativeButton时,即使dismiss()没有被调用,看起来他们都会关闭对话框。 点击一个按钮后,有没有办法保持对话框打开(如果有其他类型的positiveButton / negativeButton ,那也没关系)?

 alert { title = "Add Board" customView { .... } positiveButton("OK") { doSomeFunction() } negativeButton("Close"){} }.show() 

对于将来可能会遇到这个问题的人来说,这就是Kotlin可以做到的

 val myAlert = alert { title = "Add Board" customView { .... } positiveButton("OK") { /*Keep blank, we'll override it later*/} negativeButton("Close"){} }.show() //You can use BUTTON_NEGATIVE and BUTTON_NEUTRAL for other buttons (myAlert as AlertDialog).getButton(AlertDialog.BUTTON_POSITIVE) .setOnclickListener{ doSomeFunction() }