Kotlin / anko

Pleasant Android application development
Apache License 2.0
15.89k stars 1.29k forks source link

anko alert dialog yes no button show ok cancel test #704

Open Anilugale opened 5 years ago

Anilugale commented 5 years ago

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

iceboundrock commented 5 years ago

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.

Anilugale commented 5 years ago

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

iceboundrock commented 5 years ago

Sorry, but I dont understand your question.

Taonce commented 5 years ago

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.