Last active
July 5, 2019 11:57
-
-
Save reuniware/96dea0650fb57d1185e192805547e03f to your computer and use it in GitHub Desktop.
Alertdialog Kotlin in Fragment (with same theme as the default theme when showing from normal Activity)
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
var alertDialogBuilder = AlertDialog.Builder(context, R.style.AlertDialogThemeCustom) | |
alertDialogBuilder.setTitle("Deletion") | |
alertDialogBuilder.setMessage("Do you confirm the deletion ?") | |
alertDialogBuilder.setCancelable(false) | |
alertDialogBuilder.setPositiveButton("Yes, delete", DialogInterface.OnClickListener { dialog, which -> | |
// ... | |
dialog.cancel() | |
} ) | |
alertDialogBuilder.setNegativeButton("No, cancel", DialogInterface.OnClickListener { dialog, which -> | |
// Do nothing | |
} ) | |
val alertDialog = alertDialogBuilder.create() | |
alertDialog.show() | |
/* | |
<style name="AlertDialogThemeCustom" parent="Theme.AppCompat.Light.Dialog.Alert"> | |
<item name="android:textColor">@color/alertdialog_black</item> | |
<item name="android:windowBackground">@color/alertdialog_whitegrey</item> | |
</style> | |
<color name="alertdialog_black">#FF000000</color> | |
<color name="alertdialog_whitegrey">#FFF2F2F2</color> | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment