Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change color of Items in AlertDialog.Builder AppCompat?

How to change color of Items in AlertDialog.Builder AppCompat ?

I want to set textColor of items(photo,gallary) to any other.

here is my code:

AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.AppCompatAlertDialogStyle);
        builder.setTitle(getResources().getString(R.string.choose_image_source));
        builder.setItems(new CharSequence[]{getResources()
                        .getString(R.string.photo), getResources()
                        .getString(R.string.camera)}, new DialogInterface.OnClickListener() {

...

<style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">

        <item name="colorAccent">#000000</item><!-- buttons OK cancel-->
        <item name="android:textColorPrimary">#696969</item><!--text in message-->
        <item name="android:background">#f0a400</item> <!-- all bg-->
    </style>
    <style name="MyTitleTextStyle">
        <item name="android:textColor">#000000</item><!-- title color-->
        <item name="android:textAppearance">@style/TextAppearance.AppCompat.Title</item>
    </style>

enter image description here

like image 650
NickUnuchek Avatar asked Sep 17 '15 11:09

NickUnuchek


1 Answers

Try this:

<style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
    <item name="colorAccent">#000000</item><!-- buttons OK cancel-->
    <item name="android:textColorPrimary">#696969</item><!--text in message-->
    <item name="android:background">#f0a400</item> <!-- all bg-->
    <!-- items color -->
    <item name="textColorAlertDialogListItem">#33b5e5</item>
</style>
<style name="MyTitleTextStyle">
    <item name="android:textColor">#000000</item><!-- title color-->
    <item name="android:textAppearance">@style/TextAppearance.AppCompat.Title</item>
</style>
like image 104
Daniel Wang Avatar answered Oct 03 '22 03:10

Daniel Wang