This should be pretty easy using ExpandableListView. Extend BaseExpandableListAdapter to gain control over how group items and extended list items are displayed, and how events are triggered on them. With this, you can organize this view to display a durable group for one item and an expandable list for multiple items. With such an adapter, you can feed an ExpendableListView to make it work
An example of its implementation below. Please note that here are not all methods that should be implemented as not related to the problem. An element is some imaginary class that can themselves show how they should be displayed.
public class MyExpandableListAdapter extends BaseExpandableListAdapter {
private final List<Element> elements;
public MultiSelectExpandableListAdapter(Context c, List<Element> elements) {
this.elements = elements;
}
public View getGroupView(final int group, final boolean expanded, final View convertView,
final ViewGroup parent) {
if (elements.get(group).shouldBeDisplayedAsAGroup()) {
} else {
}
}
public View getChildView(final int group, final int child, final boolean lastChild, final View convertView,
final ViewGroup parent) {
}
}
source
share