Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom item states for android selectors

I see examples of selectors using android states like 'selected' to define style. Here 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 of

android:state_selected="true"

My goal is to color shapes based on an integer value, like simple version of this heatmap: alt text

like image 502
RichardJohnn Avatar asked Jan 22 '23 10:01

RichardJohnn


1 Answers

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

You can see a coded example here

like image 130
ilomambo Avatar answered Jan 27 '23 21:01

ilomambo