1

I have a alertdialog which contains multichoice items and all other functionality is working fine. I've a problem with the color of the checkbox it is showing is not matching with my app color. I've tried with the setcustombuilder but it is not working. Please help. I dont want to use listview.

final String[] ratings = {"2015","2016"};
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
final boolean[] ratingschecked = {false,false};
 builder.setTitle("Select Year");
    builder.setMultiChoiceItems(ratings, ratingschecked, new DialogInterface.OnMultiChoiceClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which, boolean isChecked) {
           //something
        }
    }).setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

            //something
        }
    }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

        }
    });

    AlertDialog dialog = builder.create();
    builder.show();

is there any possibilties to change the color of android checkbox color to other?

Answer:

 Created a Style file.
         <style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
          <item name="colorAccent">@color/brand</item>
         </style>

Then add this file in the App theme. It works.

         <item name="alertDialogTheme">@style/AppCompatAlertDialogStyle</item>
user2269164
  • 1,095
  • 2
  • 15
  • 31

2 Answers2

1

Use this line in your theme in styles.xml

<style>
    <item name="android:colorAccent">@android:color/holo_green_dark</item>
</style>

with color of your choice

Vivek Mishra
  • 5,669
  • 9
  • 46
  • 84
1

In this link I showed how to change standard checkbox color in multichoiceitems. It also shows how to customize the AletDialog. For example, how to change divider colro and etc. Please visit this link:

https://stackoverflow.com/a/33439849/5475941.

I hope it helps.

Community
  • 1
  • 1
Mohammad
  • 6,024
  • 3
  • 22
  • 30