在XML档案中,我有以下选定人:res/color/redeemlist_item_color.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:color="#FFFFFF" /> <!-- pressed -->
<item android:state_selected="true"
android:color="#FFFFFF" /> <!-- focused -->
<item android:color="#000000" /> <!-- default -->
</selector>
I also have a TextView
in a ListView
item layout. When I set android:textColor
on this TextView
to the above selector in XML, then the color changes correctly when the item is selected. However, I am trying to set this resource programmatically in the following way:
holder.label.setTextColor(R.color.redeemlist_item_color);
这样,肤色就不再改变。 能够以这种方式指派一名选择人到<条码>。