Created
August 30, 2019 08:24
-
-
Save bdivljak91/cab646e1d6d22453ac646d3fdab70f82 to your computer and use it in GitHub Desktop.
Show dilaog- Activity extension function
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
| fun Activity.showDialog(title: String, | |
| message: String, | |
| positiveButtonFunction: () -> Unit = {}, | |
| negativeButtonFunction: () -> Unit = {}, | |
| positiveButtonText: String = "YES", | |
| negativeButtonText: String = "NO") { | |
| val builder = AlertDialog.Builder(this) | |
| builder.setTitle(title) | |
| builder.setMessage(message) | |
| // Set a positive button and its click listener on alert dialog | |
| builder.setPositiveButton(positiveButtonText) { _, _ -> | |
| positiveButtonFunction | |
| } | |
| builder.setNegativeButton(negativeButtonText) { _, _ -> | |
| negativeButtonFunction | |
| } | |
| val dialog: AlertDialog = builder.create() | |
| dialog.show() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment