how to hide ExpandableListView indicator for groups with no children

LK Yeung picture LK Yeung · Aug 29, 2012 · Viewed 15.1k times · Source

Possible Duplicate:
ExpandableListView - hide indicator for groups with no children

hide indicator for groups with no children

main.xml

<ExpandableListView 
android:id="@+id/elv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:groupIndicator="@drawable/selector">
</ExpandableListView>

selector.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_empty="true" android:drawable="@android:color/transparent"/>
    <item android:state_expanded="true" android:drawable="@drawable/expanded" />
    <item android:drawable="@drawable/collapse" />
</selector>

it doesnt work for my ICS, it seems that the state of all collapsed groups are empty

Answer

Swayam picture Swayam · Aug 29, 2012

Have a try at this :

getExpandableListView().setGroupIndicator(null);

Or else,

if ( getChildrenCount( groupPosition ) == 0 ) {
       indicator.setVisibility( View.INVISIBLE );
    } 
else {
       indicator.setVisibility( View.VISIBLE );
       indicator.setImageResource( isExpanded ? R.drawable.group_expanded : R.drawable.group_closed );
    }