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>
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With