How can I completely hide the groupIndicator of an ExpandableListView?

AndroidExpandablelistview

Android Problem Overview


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.

Android Solutions


Solution 1 - Android

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

Solution 2 - Android

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!

Solution 3 - Android

You can try this code

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

listView.setGroupIndicator(null);


listView.setChildIndicator(null);

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPatrick DattilioView Question on Stackoverflow
Solution 1 - AndroidMichaelView Answer on Stackoverflow
Solution 2 - AndroidAjith MemanaView Answer on Stackoverflow
Solution 3 - AndroidChandrika AjmeraView Answer on Stackoverflow