Created
January 27, 2019 19:46
-
-
Save dynoChris/394f5d04a72dcc549d255e04fdcab6b9 to your computer and use it in GitHub Desktop.
How to change background color of Alert Dialog in Android
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
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.AlertDialogCustom)); | |
AlertDialog alertDialog = builder.create(); | |
alertDialog.setTitle(getResources().getString(R.string.reset_to_default)); | |
alertDialog.setMessage(getResources().getString(R.string.you_sure_to_reset)); | |
alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, getResources().getString(R.string.yes), | |
new DialogInterface.OnClickListener() { | |
public void onClick(DialogInterface dialog, int which) { | |
dialog.dismiss(); | |
} | |
}); | |
alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, getResources().getString(R.string.cancel), | |
new DialogInterface.OnClickListener() { | |
public void onClick(DialogInterface dialog, int which) { | |
dialog.dismiss(); | |
} | |
}); | |
alertDialog.show(); |
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
<!-- Alert Dialog Theme --> | |
<style name="AlertDialogCustom" parent="@android:style/Theme.Dialog"> | |
<item name="android:background">@color/colorBackground</item> | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment