在Honeycomb上更改激活的列表项背景的颜色

Int*_*ons 10 android listview android-3.0-honeycomb

对于Honeycomb,我已将listview项目设置为使用?android:attr/activatedBackgroundIndicator样式,以便在选中时保持突出显示.

如何更改突出显示的颜色?

ada*_*amp 23

使用项目定义自定义主题:

<item name="android:activatedBackgroundIndicator">@drawable/my_background</item>
Run Code Online (Sandbox Code Playgroud)

接下来,在res/drawable/my_background.xml如下图所示的状态列表.xml文件中声明drawable :http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList确保它有一个响应的项目android:state_activated="true".这是您激活的亮点.

主题步骤是可选的,(如果您选择,您可以直接使用状态列表drawable),但它提供了额外的灵活性层,因为您已经定义了ListView项目以使用该主题属性,您可以在一个中进行此更改影响使用自定义主题的任何Activity的位置.

如果您需要有关主题的更多信息,请访问:http://developer.android.com/guide/topics/ui/themes.html