bindChildView和bindGroupView相同的游标

时间:2015-03-02 19:03:17

标签: android expandablelistview

使用getChildrenCursor如何使bindChildView获得与bindGroupView相同的光标?

        @Override
        protected Cursor getChildrenCursor(Cursor groupCursor) {


            Cursor childCursor = groupCursor;//bd.ReadData("select * from images where _id="+2);


            return childCursor;
        }

这种方式返回所有组的Cursor,而不是特定于一个Group ...

1 个答案:

答案 0 :(得分:0)

通过让GroupId能够为每个孩子查询正确的行,如下所示

        @Override
        protected Cursor getChildrenCursor(Cursor groupCursor) {

            int groupPos = groupCursor.getPosition();
            int groupId = groupCursor.getInt(groupCursor.getColumnIndex("_id"));
            Log.d("data","Show data groupPos->" + groupPos + "ID->" + groupId);

            Cursor childCursor = bd.ReadData("select * from images where _id="+groupId);

            return childCursor;

        }

        @Override
        public int getChildrenCount(int groupPosition) {
            return 1;
        }