更改已禁用的微调器Android的颜色

Eup*_*r08 6 android styles spinner

当我禁用我的微调器时,它显示了带有alpha的文本,所以texte变得有点不可见,我的问题是如何改变这种颜色?PS:我不需要改变微调器的纹理颜色.

Sal*_*azi 7

在res中创建一个颜色文件夹并创建一个颜色状态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>
Run Code Online (Sandbox Code Playgroud)

和你的textview看起来像

  <TextView
    android:textColor="@color/my_text_color"
Run Code Online (Sandbox Code Playgroud)

在适配器中,您需要膨胀包含Textview的布局.在适配器构造函数中,也发送textview的id

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

        super(context,resouceId,textviewId, list);
        flater = context.getLayoutInflater();
    }
Run Code Online (Sandbox Code Playgroud)

叫它

CustomAdapter adapter = new CustomAdapter(MainActivity.this,
                R.layout.listitems_layout, R.id.title, rowItems);
Run Code Online (Sandbox Code Playgroud)