Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to hide ExpandableListView indicator for groups with no children [duplicate]

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

like image 656
LK Yeung Avatar asked Aug 29 '12 19:08

LK Yeung


1 Answers

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 );
    }
like image 188
Swayam Avatar answered Nov 15 '22 18:11

Swayam