0

i want to add white color to text in alert box(file1,file2...file4) but it shows the default color black itself.this is my alert box image Here is my java code

if (storagePermissionGrant()) {

        final Activity activity = this;
        String[] items = {"file1", "file2", "file3", "file4"};
        ContextThemeWrapper ctw = new ContextThemeWrapper(this, R.style.re);
        AlertDialog.Builder builder = new AlertDialog.Builder(ctw);
        builder.setTitle("Menu")
                .setItems(items, (dialog, which) -> {
                    switch (which) {
                        case 0:
                            MediaUtils.openfile1(activity);
                            break;
                        case 1:
                            MediaUtils.openfile2(activity);
                            break;
                        case 2:
                            MediaUtils.openfile3(activity);
                            break;
                        case 3:
                            MediaUtils.openfile4(activity);
                            break;
                        default:
                            return;
                    }
                });
        builder.show();


    }

here is my style.xml code

<style name="re" parent="@android:style/Widget.Holo.ActionBar.Solid">
    <item name="android:background">@color/colorPrimary</item>
    <item name="colorAccent">#fff</item>
    <!--title-->
    <item name="android:textColor">#fff</item>
    <!--text-->
    <item name="android:textColorPrimary">#fff</item>
    <!--selection list-->
    <item name="android:textColorTertiary">#fff</item>
</style>
sushildlh
  • 8,986
  • 4
  • 33
  • 77

1 Answers1

0

Simply, you just change your "file1" text with this code:

Html.fromHtml("<font color='#FFFFFF'>file1</font>")

This code will totally change your text color depend on your added color value. So your string array should be like this:

String[] items = {
    Html.fromHtml("<font color='#FFFFFF'>file1</font>"), 
    Html.fromHtml("<font color='#FFFFFF'>file2</font>"), 
    Html.fromHtml("<font color='#FFFFFF'>file3</font>"),
    Html.fromHtml("<font color='#FFFFFF'>file4</font>")};
Sarith Nob
  • 337
  • 2
  • 13