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.
Asked
Active
Viewed 4,822 times
8
-
1Possible duplicate of [How to change spinner text size and text color?](http://stackoverflow.com/questions/9476665/how-to-change-spinner-text-size-and-text-color) – Raptor Jan 18 '17 at 11:28
-
Not duplicate, I need to change the color of the state disabled of spinner not the color of the ensabled one – NizarETH Jan 18 '17 at 11:29
-
So you want to display it like a disabled one or it is not being displayed as a disabled one ? – Darshan Soni Jan 18 '17 at 11:36
-
not being displayed as a disabled one. – NizarETH Jan 18 '17 at 11:53
2 Answers
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