1
我想为我的文本视图分配一个text_color_selector。最初当我用android:textColor =“@ drawable/list_selector_nav_drawer_text”来做时,它工作正常(未压缩的文本颜色是黑色的)。但是当我使用下面的代码时,未压缩的文本颜色变为紫色(类似于HTML中访问过的链接的颜色)!我在做什么错:(?recyclerview的文本颜色选择器
我使用recyclerview。
public void removeNavItemSelected(View v){
if(v!= null) {
TextView tview;
tview = (TextView) v.findViewById(R.id.title);
tview.setTextColor(R.drawable.list_selector_nav_drawer_text); // Why on this earth color becomes purple rather than black !!!
}
}
list_selector_nav_drawer_text
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true"
android:color="@color/blue" >
</item>
<item android:color="@color/black" >
</item>
</selector>
非常感谢。我也刚刚发现自己的解决方案,但并没有明白其中的道理。感谢您的解释。 – abdfahim
谢谢,效果很好。 – Ali