6

重複の可能性:
ExpandableListView-子のないグループのインジケーターを非表示にする

子供がいないグループのインジケーターを非表示にする

main.xml

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

セレクター.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>

私のICSでは機能しません。折りたたまれたグループの状態はすべて空のようです。

4

1 に答える 1

12

これを試してください:

getExpandableListView().setGroupIndicator(null);

あるいは、

if ( getChildrenCount( groupPosition ) == 0 ) {
       indicator.setVisibility( View.INVISIBLE );
    } 
else {
       indicator.setVisibility( View.VISIBLE );
       indicator.setImageResource( isExpanded ? R.drawable.group_expanded : R.drawable.group_closed );
    }
于 2012-08-29T19:43:34.423 に答える