How can I completely hide the groupIndicator of an ExpandableListView?
Asked Answered
B

3

69

I want to completely hide the groupIndicator in a custom ExpandableListView.

The example provided here did not seem to work.

It suggests making a selector and using expList.setGroupIndicator(selector), which I replicated:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/empty_icon">
    <item android:state_empty="true" android:drawable="@android:color/transparent"/>
    <item android:state_expanded="true" android:drawable="@android:color/transparent" />
    <item android:drawable="@android:color/transparent" />
</selector>

This gives the following error
ERROR/AndroidRuntime(10675): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x12/d=0x0 a=2 r=0x7f0b0013}

The same is given by the similar suggestion of using android:id/empty in place of color/transparent.

How can I completely hide the group indicator?

Edit: As it turns out, that code DOES work... if you put it in the drawable resource folder instead of layout.

Breve answered 2/5, 2011 at 3:48 Comment(0)
R
248

Have you tried changing ExpandableListView's attribute android:groupIndicator="@null"?

Rumrunner answered 2/5, 2011 at 4:42 Comment(1)
Also for anyone who want to do this programmatically, it can be done with mExpandableListView.setGroupIndicator(null).Brewis
R
0

I had the same problem and this solveed my issue. In your Listview's adapter add the following to the getGroupView.

if (groupPosition == 0) {
     convertView = layoutInflater.inflate(R.layout.blank_layout, null);

} else {
    convertView = layoutInflater.inflate(R.layout.group_indicator_cell,null);
}

This will blank the 0th groupof the list.

Where blank layout is a layout with some view inside having layout_height=0dp. It works!

Ruscher answered 22/3, 2013 at 11:1 Comment(0)
D
0

You can try this code

listView = (ExpandableListView) view.findViewById(R.id.listView);

listView.setGroupIndicator(null);


listView.setChildIndicator(null);
Date answered 24/11, 2015 at 10:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.