Custom item states for android selectors

I see examples of selectors using android states of type "selected" to define a style. Here's a simplified example:

<selector> <item android:state_selected="true" android:drawable="@color/transparent" /> <item android:drawable="@drawable/listitem_normal" /> </selector> 

So my question is: can I define and use my own state instead

 android:state_selected="true" 

My goal is color figures based on integer values, such as a simple version of this map: alt text

+4
source share
2 answers

Take a look at LevelList and LevelListDrawable , it looks like you can use drawable.

+4
source

What you originally wanted can be accomplished with custom boolean attributes.

Here you can see the encoded example.

+5
source

All Articles