Duplicates In My Expandablelistview Adapter
the problem goes is that everytime I add more than one Child to a GroupItem in my ExpandableListView, the item duplicates itself with the previous child. I have narrowed it down to
Solution 1:
@OverridepublicintgetChildCount(.....)
{
return2;
}
If you are sure that for every item there are only 2 subitems Sorry my bad this is the right method you want. EDIT
@Override
publicintgetChildrenCount(int groupPosition)
{
return (rCollection.get(weekdata.get(groupPosition())).size();
}
This will return the size (length) of your List<Custom>
for a map.
balance paranthesis if needed
Solution 2:
am not sure if you found a solution but here is what worked for me; since i was returning a recyclerview in the child view, just return 1 in getChildrenCount() method.
That's it
Solution 3:
I dug it out of some old repo, I think this is what I ended up doing.
publicintgetChildrenCount(int groupPosition) {
// Fixes a bunch of NPE when the groupPosition = NULL. This way it checks and returns 0 when it = null.
List<MySQLWeek> group = rCollection.get(weekData.get(groupPosition));
if (group == null){
return0;
}
returngroup.size();
}
Post a Comment for "Duplicates In My Expandablelistview Adapter"