How to get all childs view in group with ExpandableListView

不问归期 提交于 2019-12-19 10:14:18

问题


I am using expandable list view with checkboxex. I need to check all child boxes when I check group checkbox. How to get all child views in group?

public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {

    if (convertView == null) {
        LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        groupRow = vi.inflate(R.layout.season, parent, false);

    } else {
        groupRow = convertView;
    }
    TextView seasonTitle = (TextView) groupRow.findViewById(R.id.season_title);
    seasonTitle.setText(getGroup(groupPosition).toString());
    CheckBox checkBox = (CheckBox) groupRow.findViewById(R.id.season_check_box);

    checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            ???
        }
    });

    return groupRow;
}

回答1:


Try using ArrayList containing Boolean objects, this way you can set them all to "checked", or all to "unchecked" with the groupcheckbox.



来源:https://stackoverflow.com/questions/6924977/how-to-get-all-childs-view-in-group-with-expandablelistview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!