tags:

views:

217

answers:

2

How to customize the color of the CheckMark color in android in a dialog. Currently , By default, the color of the checkmark is green by default. I would like to customize it to a different color of choice

A: 

You have to override checkbox widget styles with modified drawable resources. Here is good guide to start with styles/themes http://brainflush.wordpress.com/2009/03/15/understanding-android-themes-and-styles/

Konstantin Burov
+2  A: 

If you look at the styles.xml from android system, you will see that the checkbox style is defined as follows :

<style name="Widget.CompoundButton.CheckBox">
   <item name="android:background">@android:drawable/btn_check_label_background</item>
   <item name="android:button">@android:drawable/btn_check</item>
</style>

And If you search the resources of the system, you will see that btn_check is a drawable selector with 2 states (on/off) with the check colored green or not.
So if you want to have your own color-drawable, here is what you should do :
- create a styles.xml
- define the 2 drawables to use
- create the xml file supporting the selector

You can find the full documentation quite detailled on the android google doc.

Sephy
Hi, I still could not succeed in implementing the solution.
Karthik
Can u please help me with a bit more information regarding the same. I have pasted a sample java file for the same. Please help me what exactky i need to do to to have my checkbox color to be changed to some other color instead of red.
Karthik
AlertDialog.Builder checkbox_dialog = new AlertDialog.Builder( DialogCheckBox.this); checkbox_dialog.setTitle("Main Title goes here"); checkbox_dialog.setMultiChoiceItems(myitems, choiceitems, new DialogInterface.OnMultiChoiceClickListener() { public void onClick(DialogInterface dialog, int which, boolean isChecked) { Log.d("TAG","items getting selected"); } });
Karthik
Please edit your first post with this code, this will help next users to find answers to their questions more easily and we will also have a better display with the code styling. You should add your java code, the xml file of your selector to see if there is something wrong.
Sephy