gpt4 book ai didi

android - 如何删除 ExpandableListView 中特定组(行)的箭头

转载 作者:搜寻专家 更新时间:2023-11-01 08:01:09 28 4
gpt4 key购买 nike

默认情况下,每个组都有一个向下的箭头,向用户指示该项目可以展开。但是,我有一组没有 child ;因此,我希望此项目上不显示箭头。

最佳答案

根据文档:

public void setGroupIndicator (Drawable groupIndicator)
Sets the indicator to be drawn next to a group.

ParametersgroupIndicator The drawable to be used as an indicator. If the group is empty, the state state_empty will be set. If the group is expanded, the state state_expanded will be set.

所以假设,这应该已经做了正确的事情...但是,如果您使用自己的自定义 ExpandableListAdapter,例如使用 TextViews,您可以使用以下代码:

// in your main file where the List is defined:
mExpandableList.setGroupIndicator(null); // this will remove the indicator

然后在您的自定义适配器中,您可以执行以下操作:

@Override
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {

View v;
...
// code to retrieve convertView or inflate new one and assign to v
...

TextView tv = ((TextView) v);
int iconId; // assume we have an icon we want to have on the left of each group
int expandableGroupResId;

if (getChildrenCount(groupPosition) > 0) {
if (isExpanded) expandableGroupResId = R.drawable.expander_ic_maximized;
else expandableGroupResId = R.drawable.expander_ic_minimized;
}
tv.setCompoundDrawablesWithIntrinsicBounds(iconId, 0, expandableGroupResId, 0);
}

关于android - 如何删除 ExpandableListView 中特定组(行)的箭头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21081349/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com