Change colour of activated list item background on Honeycomb

后端 未结 1 1750
既然无缘
既然无缘 2020-12-25 09:19

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

How do

相关标签:
1条回答
  • 2020-12-25 10:25

    Define a custom theme with the item:

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

    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.

    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.

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

    0 讨论(0)
提交回复
热议问题