anko
anko copied to clipboard
anko alert dialog yes no button show ok cancel test
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
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.