So I'm trying to set a custom ExpandableListView indicator icon but it isn't working. I created an icon and saved it to drawable folder. Here are the icons:
This is the selector:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/arrow_up" android:state_empty="true"/>
<item android:drawable="@drawable/arrow_down" android:state_activated="true"/>
</selector>
ExpandableListView xml:
<ExpandableListView
android:id="@+id/lvExp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:groupIndicator="@drawable/custom_arrow" />
However, when I launch the app, there is not indicator at all. Any idea what I have done wrong?
this should do the trick
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_expanded="true" android:drawable="@drawable/arrow_up" />
<item android:drawable="@drawable/arrow_down" />
</selector>
you wanted the state_expanded
for when the row gets expanded and then any other state besides expanded is just the normal down arrow. You should however handle the state_empty
when there is nothing to expand to
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