1

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.

Ajinkya
  • 2,286
  • 3
  • 18
  • 25

1 Answers1

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

Community
  • 1
  • 1
uday
  • 1,348
  • 12
  • 27
  • 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