state_activated和ListView项的背景颜色
我试图颜色项目的(选择)的背景。我与Android模拟器的工作。我在水库一组XML文件/绘制
。
I'm trying to color an item's (when selected) background. I'm working with the Android emulator. I have a set of XML files in res/drawable
.
background.xml:
background.xml :
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/pressed" />
<item android:drawable="@drawable/normal" />
</selector>
normal.xml:
normal.xml :
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#000000" />
</shape>
pressed.xml:
pressed.xml :
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#33ffff" />
</shape>
和我list_item.xml,与...我的项目:&LT; TextView的......机器人:背景=@绘制/背景机器人:填充=6DP/&GT;
And my list_item.xml, with...my item :
<TextView ... android:background="@drawable/background" android:padding="6dp" />
那么,在模拟器 STATE_ pressed =真正的
的作品,但是我希望所选择的项目仍然是有色。所以,相反的 STATE_ pressed
我试过 state_activated
...但是哎...不工作太。我的项目仍然是黑...
Well, in the emulator state_pressed="true"
works, however I want that the selected item remains colored. So, instead of state_pressed
I tried state_activated
...but hey...doesn't works too. My item remains black...
需要一些帮助:)!
感谢您
请参照下面的链接:
http://developer.android.com/resources/tutorials/意见/ HELLO-formstuff.html
尝试使用state_focused为你的案件。
try using state_focused for your case.
谢谢!