I am using the AlertDialog.Builder class to builder the alert with the radio buttons and the cancel button and I want to change the color of the divider and the radio button color how to do this can any one please provide solution.I checked all the answer from the stackoverflow about this related question. And one more i am using the v7Appcomapact Library.My min sdk is 10 and maximum is 18. I don't want to use the custom layout.
Asked
Active
Viewed 924 times
1
-
`v7Appcomapact` doesn't provide customization of `AlertDialogs` if you want to achieve `Material Dialogs` you can try this library https://github.com/afollestad/material-dialogs – Nitin Misra Dec 20 '14 at 05:54
-
My project lower version is 18 not the 21?Can i use that library. – Ajinkya Dec 20 '14 at 08:56
-
yes for sure, you can use the above said library – Nitin Misra Dec 20 '14 at 09:34
-
Thanx...but i manage to change the color of divider... – Ajinkya Dec 28 '14 at 04:53
1 Answers
1
try this
public static void brandAlertDialog(AlertDialog dialog) {
try {
Resources resources = dialog.getContext().getResources();
int color = resources.getColor(...); // your color here
int alertTitleId = resources.getIdentifier("alertTitle", "id", "android");
TextView alertTitle = (TextView) dialog.getWindow().getDecorView().findViewById(alertTitleId);
alertTitle.setTextColor(color); // change title text color
int titleDividerId = resources.getIdentifier("titleDivider", "id", "android");
View titleDivider = dialog.getWindow().getDecorView().findViewById(titleDividerId);
titleDivider.setBackgroundColor(color); // change divider color
} catch (Exception ex) {
ex.printStackTrace();
}}
already answered here
-
I said i have seen all the answer from the stackoverflow before.The function u have give me its parameter is AlertDialog i want for the Alertdialog.builder. If i used the the AlertDialog.Builder in your function give me an error at the "getWindow()" the error is can't resolves the method 'getWindows()'. – Ajinkya Dec 20 '14 at 08:49