8

When I disable my spinner it's dispalyed a text with an alpha so texte become a little not visible, my question how I can change this color ? PS : I don't need to change the color of the spinner's texte.

NizarETH
  • 969
  • 3
  • 15
  • 38

2 Answers2

11

Create a color folder in res and create a color state my_text_color.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:color="@color/disableColor" android:state_enabled="false"/>
    <item android:color="@color/enableColor"/>
</selector>

and your textview look like

  <TextView
    android:textColor="@color/my_text_color"

In adapter you need to inflate the layout that contain the Textview. Inside your adapter constructor, send the id of textview also

public CustomAdapter(Activity context,int resouceId, int textviewId, List<RowItem> list){

        super(context,resouceId,textviewId, list);
        flater = context.getLayoutInflater();
    }

call it by

CustomAdapter adapter = new CustomAdapter(MainActivity.this,
                R.layout.listitems_layout, R.id.title, rowItems);
Dbl
  • 5,634
  • 3
  • 41
  • 66
Salauddin Gazi
  • 1,497
  • 1
  • 13
  • 18
3
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_enabled="false" android:color="@color/disabled_color"/>
    <item android:color="@color/normal_color"/>
</selector>

<EditText
    android:id="@+id/customEditText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:enabled="false"
    android:text="Hello!"
    android:textColor="@drawable/edit_text_selector" />

// first code used in drawable/edit_text_selector.xml

Vicky Mahale
  • 1,209
  • 11
  • 18