开发者

How can I completely hide the groupIndicator of an ExpandableListView?

开发者 https://www.devze.com 2023-03-02 05:17 出处:网络
I want to completely hide the groupIndicator in a custom Exp开发者_开发技巧andableListView. The example provided here did not seem to work.

I want to completely hide the groupIndicator in a custom Exp开发者_开发技巧andableListView.

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.


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


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!


You can try this code

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

listView.setGroupIndicator(null);


listView.setChildIndicator(null);
0

精彩评论

暂无评论...
验证码 换一张
取 消