激活列表项的背景蜂窝状改变颜色 [英] Change colour of activated list item background on Honeycomb

查看:93
本文介绍了激活列表项的背景蜂窝状改变颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关蜂窝,我已经把我的列表视图的项目使用安卓?ATTR / activatedBackgroundIndicator 的风格,使他们保持选中状态时,强调

For Honeycomb, I have set my listview items to use the ?android:attr/activatedBackgroundIndicator style so they remain highlighted when selected.

我如何更改高亮颜色的?

How do I change the colour of the highlight?

推荐答案

定义自定义主题的项目:

Define a custom theme with the item:

<item name="android:activatedBackgroundIndicator">@drawable/my_background</item>

接下来,声明在 RES /绘制/ my_background.xml 如左图所示的绘制在状态列表.xml文件:<一href="http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList">http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList请确保它有响应 Android的一个项目:state_activated =真正的。这是你的激活亮点。

Next, declare that drawable in a state list .xml file under res/drawable/my_background.xml as illustrated here: http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList Make sure that it has an item that responds to android:state_activated="true". This is your activated highlight.

主题步骤是可选的,(你可以直接使用状态列表绘制的,如果你选择,),但它给出了灵活的附加层,因为你已经确定你的ListView项目使用该主题的属性可以让这个在一个地方更改会影响使用自定义主题的活动。

The theme step is optional, (you could use the state list drawable directly if you choose,) but it gives an added layer of flexibility and since you've already defined your ListView items to use that theme attribute you can make this change in one place to affect any Activity that uses the custom theme.

如果您需要在主题的详细信息请看这里:<一href="http://developer.android.com/guide/topics/ui/themes.html">http://developer.android.com/guide/topics/ui/themes.html

If you need more info on themes look here: http://developer.android.com/guide/topics/ui/themes.html

这篇关于激活列表项的背景蜂窝状改变颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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