anko alert dialog yes no button show ok cancel test

Created on 28 Nov 2018  Â·  4Comments  Â·  Source: Kotlin/anko

alert("Hi, I'm Roy", "Have you tried turning it off and on again?") {
yesButton { toast("Oh…") }
noButton {}
}.show()

this is show ok cancel button

Most helpful comment

This is expected and here is why.

For AlertBuilder, the yesButton and noButton are nothing but simple extension methods on top of positiveButton and negativeButton:

inline fun AlertBuilder<*>.yesButton(noinline handler: (dialog: DialogInterface) -> Unit) =
    positiveButton(android.R.string.yes, handler)

inline fun AlertBuilder<*>.noButton(noinline handler: (dialog: DialogInterface) -> Unit) =
    negativeButton(android.R.string.no, handler)

In Andorid SDK, the default value of android.R.strings.yes is OK and android.R.strings.no is Cancel, here is the code link

You can always use positiveButton and negativeButton to customize the text.

All 4 comments

This is expected and here is why.

For AlertBuilder, the yesButton and noButton are nothing but simple extension methods on top of positiveButton and negativeButton:

inline fun AlertBuilder<*>.yesButton(noinline handler: (dialog: DialogInterface) -> Unit) =
    positiveButton(android.R.string.yes, handler)

inline fun AlertBuilder<*>.noButton(noinline handler: (dialog: DialogInterface) -> Unit) =
    negativeButton(android.R.string.no, handler)

In Andorid SDK, the default value of android.R.strings.yes is OK and android.R.strings.no is Cancel, here is the code link

You can always use positiveButton and negativeButton to customize the text.

show why don't you add function to add custom title

Sorry, but I dont understand your question.

I think you got it wrong,yesButton and noButton has nothing to do with the title,it decision is to confirm and cancel the button text.You can reframe your question.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AndwareSsj picture AndwareSsj  Â·  4Comments

HarryTylenol picture HarryTylenol  Â·  3Comments

telenc picture telenc  Â·  3Comments

bapspatil picture bapspatil  Â·  4Comments

SalomonBrys picture SalomonBrys  Â·  3Comments