library / org.akop.kotx.ext.app / android.content.Context / showAlertDialog

showAlertDialog

fun Context.showAlertDialog(message: String? = null, title: String? = null, block: AlertDialogBuilder.() -> Unit = {}): Dialog

Displays an alert dialog by creating a new AlertDialogBuilder using the title and message provided, then passing it to block with the builder as receiver.

Example usage:

showAlertDialog("Danger zone?") {
    positiveButton("yes") { _, _ -> deleteAll() }
    negativeButton("no")
}

Return
Instance of displayed dialog.

fun Context.showAlertDialog(@StringRes messageResId: Int, @StringRes titleResId: Int = 0, block: AlertDialogBuilder.() -> Unit = {}): Dialog

Displays an alert dialog by creating a new AlertDialogBuilder using the title and message string resource ids provided, then passing it to block with the builder as receiver.

Example usage:

showAlertDialog(R.string.delete_everything) {
    positiveButton(R.string.yes) { _, _ -> deleteAll() }
    negativeButton(R.string.no)
}

Return
Instance of displayed dialog.