I have an expandableList using two cursors: 1 for the group, another for the children associated with the group. The user can use a filter (alphaindexer) in this expandable list. I would like to completely remove the group view when there are no children (not just the icon :)). As if I am deleting a row for an empty group.
I am trying to set the visibility in the bindgroupview method. I am trying to set the height of the layout for group viewing .... The result is the same, the space is still saved and displayed.
Is it possible and how to do it?
The following code is below:
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) {
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];
}
@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() {
return false;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
}
source
share