state_activated和ListView项的背景颜色 [英] state_activated and ListView item background color

查看:133
本文介绍了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.

谢谢!

这篇关于state_activated和ListView项的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆