Reputation: 329
I want to hide the whole group from ExpandableListView
if it has no child(s). I've tried to use this in the public View getGroupView
:
if (getChildrenCount(groupPosition) == 0) {
convertView.setVisibility(View.INVISIBLE);
lblListHeader.setVisibility(View.INVISIBLE);
} else {
convertView.setVisibility(View.VISIBLE);
lblListHeader.setVisibility(View.VISIBLE);
}
But that is not working I still see the indicator (the text is removed) and a empty space.
Also I've tried this:
if (getChildrenCount(groupPosition) == 0) {
convertView = layoutInflater.inflate(R.layout.blank_layout, null);
}
That's working but when I try to open another group I get a java.lang.NullPointerException
.
Is it possible to hide group(s) from ExpandableListView
if it has no child(s)?
Upvotes: 3
Views: 1973
Reputation: 29912
You have to implement the datamodel in the adapter so that it allows removal and then once you have it removed you set invoke notifyDataSetChanged() on the adapter.
Upvotes: 1