Home » Android » android – Anko dialog button title

android – Anko dialog button title

Posted by: admin June 15, 2020 Leave a comment


With Anko, I can write something like this for showing dialog:

alert("Dialog title") {
   yesButton {}
   noButton {}

How can I set a title for the button?

noButton {title = "title"}

Unfortunately, it doesn’t work.

How to&Answers:

You can use positiveButton and negativeButton like so:

alert("Dialog title") {
    positiveButton("Yes") { it.dismiss() }
    negativeButton("No") { it.dismiss() }