首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何才能完全隐藏ExpandableListView的groupIndicator?

如何才能完全隐藏ExpandableListView的groupIndicator?
EN

Stack Overflow用户
提问于 2011-05-02 11:48:07
回答 3查看 35.3K关注 0票数 69

我想在自定义ExpandableListView中完全隐藏groupIndicator。

here提供的示例似乎不起作用。

它建议创建一个选择器并使用expList.setGroupIndicator(选择器),我复制了它:

<?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>

这将产生以下错误

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}

使用android:id/empty代替color/transparent的类似建议也给出了同样的结论。

怎样才能完全隐藏群指标?

编辑:事实证明,这些代码确实可以工作……如果您将其放在可绘制资源文件夹中,而不是布局中。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2011-05-02 12:42:33

您是否尝试过更改ExpandableListView的属性android:groupIndicator="@null"

票数 248
EN

Stack Overflow用户

发布于 2013-03-22 19:01:22

我也有同样的问题,这解决了我的问题。在Listview的适配器中,将以下内容添加到getGroupView中。

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

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

这将使列表的第0组空白。

其中,空白布局是内部具有layout_height=0dp的某个视图的布局。它起作用了!

票数 0
EN

Stack Overflow用户

发布于 2015-11-24 18:13:47

你可以试试这段代码

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

listView.setGroupIndicator(null);


listView.setChildIndicator(null);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5853305

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档