gpt4 book ai didi

android - 在可扩展列表中隐藏组 View

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:27:55 27 4
gpt4 key购买 nike

我有一个使用两个游标的 expandableList:1 个用于组,另一个用于与组相关的子项。用户可以在此可扩展列表上使用过滤器 (alphaindexer)。我想在没有 child 时完全删除组 View (不仅是图标 :))。就像我删除了空组的行。

我尝试在 bindgroupview 方法中将可见性设置为消失。我尝试为组 View 设置布局高度....结果是一样的,空间仍然保留并显示。

这可能吗?我该如何实现此功能?

下面的一些代码:

// mMapSeqArticle is TreeMap<Object, ArrayList<Object>)
mSequenceAdapter = new SequenceCommandeAdapter(getActivity(), mMapSeqArticle);

public class SequenceCommandeAdapter extends BaseExpandableListAdapter {
Object[] mGroupSeq = null;
Map<Sequence, ArrayList<TicketArticle>> mContent;

public SequenceCommandeAdapter(Context c,
Map<Sequence, ArrayList<TicketArticle>> map) {
mContent = map;
mGroupSeq = mContent.keySet().toArray();
}

@Override
public Object getChild(int groupPosition, int childPosition) {
Sequence s = (Sequence) mGroupSeq[groupPosition];
return ((ArrayList<TicketArticle>) (mContent.get(s)))
.get(childPosition);
}

@Override
public long getChildId(int groupPosition, int childPosition) {
Sequence s = (Sequence) mGroupSeq[groupPosition];
return ((ArrayList<TicketArticle>) (mContent.get(s)))
.get(childPosition).mId;
}

@Override
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
// retrouve la valeur de la sequence
TicketArticle ta = (TicketArticle) getChild(groupPosition,
childPosition);
if (convertView == null) {
convertView = LayoutInflater.from(getActivity()).inflate(
R.layout.adapter_row_article_details_table, null);
}



convertView.setTag(groupPosition + ":" + childPosition);
return convertView;
}

@Override
public int getChildrenCount(int groupPosition) {
Sequence s = (Sequence) mGroupSeq[groupPosition];
return ((ArrayList<TicketArticle>) (mContent.get(s))).size();
}

@Override
public Object getGroup(int groupPosition) {
return (Sequence) mGroupSeq[groupPosition];// mContent.get(groupPosition);
}

@Override
public int getGroupCount() {
return mContent.size();
}

@Override
public long getGroupId(int groupPosition) {
return ((Sequence) mGroupSeq[groupPosition]).key;
}

@Override
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(getActivity()).inflate(
R.layout.adapter_header_sequence_details_table, null);
}


convertView.setTag(null);
return convertView;
}

@Override
public boolean hasStableIds() {
// TODO Auto-generated method stub
return false;
}

@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
// TODO Auto-generated method stub
return true;
}
}

最佳答案

我在您的代码中没有看到 bindGroupView 方法,但根据您的描述,您似乎走在了正确的轨道上。我必须将所有 subview (包括布局)的可见性设置为 GONE,以便组行从可扩展 ListView 中完全消失。否则,将保留空行。

如果你发布 R.layout.adapter_header_sequence_details_table 的内容,我会更好地了解你需要做的其他事情。

关于android - 在可扩展列表中隐藏组 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14628526/

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