Reputation: 3
Is there an API or any official way to remove the group indicator for the item which does not has children when use a CursorTreeAdapter for a ExpandableListView?
Help! thanks a lot.
Upvotes: 0
Views: 1647
Reputation: 4521
I struggled with this thing for a long time, the way I ended up doing it was to hide completely the GroupIndicator from the ExpandableListView
<ExpandableListView android:id="@+id/android:list"
android:layout_below="@id/technical_details_label_separator"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:drawSelectorOnTop="false"
android:groupIndicator="@android:color/transparent"
/>
Then I created a Custom adapter extending BaseExpandableListAdapter, and implemented the getGroupView method, inside this method you can create a View with an ImageView that you can switch manually to expand or contract the group (using the isExpanded flag), and hide it completely if the group was empty.
http://developer.android.com/reference/android/widget/ExpandableListAdapter.html#getGroupView(int, boolean, android.view.View, android.view.ViewGroup)
Upvotes: 2