My uses an expandable list adapter. I ran into a problem when I update
the adapter content. Here is the sequence of events:
1) Adapter contains groups A, B, C. Group A and C contain 2 children
2) I update the adapter data (I call notifyDataSetChanged) due to the
fact that Group B is removed by the user
3) If group C was expanded the code crashes in getChildrenCount
because it gets called with a groupPosition which is 3 (the old number
of groups)
@Override
public int getChildrenCount( int groupPosition)
{
if( groupPosition >= m_groups.size())
{
Log.e( "getChildrenCount", "Group index: " + groupPosition);
return 0;
}
return m_groups.get(groupPosition).getBuddies().size();
}
If I check that the group position is correct and return 0 for the
children count the problem goes away. Also, if group C was not
collapsed before I removed group B the crash does not occur because
getChildrenCount is not called (makes sense).
It seems to me that the adapter is using the old size of the groups
array to do something with the expanded items. If the last item is
expanded a crash would occur.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---