开发者

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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜