Problem of dynamic binding data with ExpandableListView on Android
First thing, is this the correct way to get the current item view of an expandablelistview?
long packedPosition = ExpandableListView.getPackedPositionForChild(groupPosition, childPosition);
int flatListPosition = myExpandableListView.getFlatListPosition(packedPosition);
View v = myExpandableListView.getChildAt(flatListPosition - expandableListView.getFirstVisiblePosition());
I used an asyncta开发者_StackOverflowsk to get an image and bind it to the item view when it gets callback. The result seems ok, but sometimes it crashed at the internal method (NullPointerException) of the ExpandableListView class as following.
public int getFlatListPosition(long packedPosition) {
PositionMetadata pm = mConnector.getFlattenedPos(ExpandableListPosition
.obtainPosition(packedPosition));
**final int flatListPosition = pm.position.flatListPos;**
pm.recycle();
return getAbsoluteFlatPosition(flatListPosition);
}
Maybe this is caused by the behavior that I keep trying to expand and collapse the groups. Any help?
Thanks!
精彩评论