anko
anko copied to clipboard
YesButton and NoButton text
Is It possible to change YesButton and NoButton text?
I assume that you are referring to the AlertBuilder class since AlertDialogBuilder
is deprecated.
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)
so I think you can just call the positiveButton
and negativeButton
with the text you like.
I assume that you are referring to the AlertBuilder class since
AlertDialogBuilder
is deprecated.For AlertBuilder, the
yesButton
andnoButton
are nothing but simple extension methods on top ofpositiveButton
andnegativeButton
: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)
so I think you can just call the
positiveButton
andnegativeButton
with the text you like.
How can I call this in Anko dialogs?
Something like this:
alert {
positiveButton("YES!!!", {})
negativeButton("NOPE!!!, {})
// something else ...
}
And you can use resource id
instead of literal string.