[英]Change color of a disabled spinner Android
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 ? 当我禁用我的微调器时,它显示了一个带有alpha的文本,所以texte变得有点不可见,我的问题是如何改变这种颜色? PS : I don't need to change the color of the spinner's texte.
PS:我不需要改变微调器的纹理颜色。
Create a color folder in res and create a color state my_text_color.xml 在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>
and your textview look like 和你的textview看起来像
<TextView
android:textColor="@color/my_text_color"
In adapter you need to inflate the layout that contain the Textview. 在适配器中,您需要膨胀包含Textview的布局。 Inside your adapter constructor, send the id of textview also
在适配器构造函数中,也发送textview的id
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);
<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 //在drawable / edit_text_selector.xml中使用的第一个代码
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.