Created
February 15, 2021 13:38
-
-
Save abircse/52e94ad5a0ff7e600121315ea84c6fb0 to your computer and use it in GitHub Desktop.
AlertDialogExtension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline fun showMessegeDialogWithAction(ctx: Context, msg: String, btnTxtPositive: String, btnTxtNegative: String, crossinline onPositiveButtonClick: () -> Unit){ | |
val builder = AlertDialog.Builder(ctx) | |
builder.setMessage(msg) | |
builder.setIcon(android.R.drawable.ic_dialog_alert) | |
builder.setPositiveButton(btnTxtPositive) { dialogInterface, which -> | |
onPositiveButtonClick.invoke() | |
} | |
builder.setNegativeButton(btnTxtNegative) { dialogInterface, which -> | |
dialogInterface.dismiss() | |
} | |
val alertDialog: AlertDialog = builder.create() | |
alertDialog.setCancelable(false) | |
alertDialog.show() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment