anko icon indicating copy to clipboard operation
anko copied to clipboard

anko alert dialog yes no button show ok cancel test

Open Anilugale opened this issue 6 years ago • 4 comments

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

Anilugale avatar Nov 28 '18 10:11 Anilugale

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.

iceboundrock avatar Dec 18 '18 07:12 iceboundrock

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

Anilugale avatar Dec 26 '18 05:12 Anilugale

Sorry, but I dont understand your question.

iceboundrock avatar Dec 26 '18 05:12 iceboundrock

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.

Taonce avatar Dec 28 '18 02:12 Taonce