After a bit of debugging, I finally found out that, strangely enough, getChildrenCount
is never called after I called notifyDataSetChanged
. Thus, the Adapter is still expecting to get the same number of children as there were before the update.
As I removed some children, that's a wrong assumption, and leads to the IndexOutOfBoundsException
.
After a bit of playing around, I discovered that for ExpandableListViews
, the Adapter has to be accessed via getExpandableListAdapter()
, not via getAdapter().
After changing my code to
((BaseExpandableListAdapter) myExpandableListView.getExpandableListAdapter()).notifyDataSetChanged();
Everything works fine now.
I hope this helps any fellow developers. I spent a few hours finding and fixing this, and hardly found any information about it on the web and StackOverflow.