在expandablelistview Android中修改子项的父状态

时间:2014-10-10 03:59:40

标签: android android-listview expandablelistview

我正在使用带有CursorTreeAdapter的expandablelistview,我试图从子视图中更改父视图中视图的状态,这可能吗?

或者每个组视图的父级是否可以收听其子级的更改?

如果问题不够明确,我就会尝试这样做,

父级有一个CheckBox,它的所有子级都有自己的复选框,我希望在选中所有子复选框时检查父级复选框状态。

当我有很多组视图时,同样如此,每个父/ GrouView都会听取自己的孩子。

更新添加代码

public class UsersAdapter extends CursorTreeAdapter {



    public UsersAdapter(Cursor cursor, Context context, Cursor dialogCuror) {
        super(cursor, context);

    }


    protected void bindChildView(View view, Context context, Cursor cursor,
            boolean arg3) {

        //this is where I use the child views including the check boxes of the children
    }

    @Override
    protected void bindGroupView(View view, Context context,
            final Cursor cursor, boolean isExpanded) {

     //This is where I use the views of the Group view including the check boxes
     // of the parent

    }

    @Override
    protected Cursor getChildrenCursor(Cursor groupCursor) {

        return new DBHelper(context).queryGroupChildren(id);
    }

    @Override
    protected View newChildView(Context context, Cursor cursor,
            boolean isLastChild, ViewGroup parent) {
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(context.LAYOUT_INFLATER_SERVICE);
        return inflater.inflate(R.layout.exp_child_item, parent, false);

    }

    @Override
    protected View newGroupView(Context context, Cursor cursor,
            boolean isExpanded, ViewGroup parent) {
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(context.LAYOUT_INFLATER_SERVICE);
        return inflater.inflate(R.layout.exp_group_item, parent, false);
    }

}

0 个答案:

没有答案