Android – Hide drawable for expandable list when there are no children


Found some similar questions but no answers that work. Right now I am doing this:

private ExpandableListView elv;


<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="">
    <item android:state_empty="true" android:drawable="@android:color/transparent"/>

Unfortunately, this hides the indicator for all groups even if they are not empty. It appears that when a group is not expanded, android considers it empty. Any tips? Thanks.

Best Solution

I did something similar to your task - to show a custom group indicator next to the group name of only some of the groups. I did it by first hiding the group indicator at all using the method setGroupIndicator(null). Then I implemented a subclass of BaseExpandableListAdapter and inside the getGroupView() method I showed or hid my own indicator image based on my logic. You may use such an approach, if that is still current. I hope I helped you.

Related Question