Android ExpandableListView在bindChildView中获取组号

时间:2012-01-15 18:10:25

标签: android expandablelistview

我正在使用ExpandableListView和SimpleCursorTreeAdapter。是否有可能在bindChildView方法中获取当前子项所属的组号?

谢谢!

1 个答案:

答案 0 :(得分:3)

我尝试了另一种使用getChildView获取组和子位置的方法:

    @Override
    public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
        ImageButton ib=null;

        View v = super.getChildView(groupPosition, childPosition,isLastChild, convertView, parent);
        ib=(ImageButton)v.findViewById(R.id.delete);

        ib.setTag(R.id.TAG_GROUPPOS, groupPosition);
        ib.setTag(R.id.TAG_CHILDPOS, childPosition);

        return v;
    }