ExpandableListView中的单选按钮

时间:2015-11-03 12:58:09

标签: android radio-button expandablelistview

我在expandablelistview中有子项目的单选按钮(它还包含复选框)。我希望他们(单选按钮)像一个广播组一样。我在getChildView中添加了以下代码,但是它不起作用。我应该更改此代码吗?我应该在onChildClickListener中添加什么?

if (rad_group.equals("rg1")) { // children, that should have radiobuttons

            rbut.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    if (isChecked) {
                        mSelectedChildPosition = childPosition;
                        mSelectedGroupPosition = groupPosition;
                        notifyDataSetChanged();

                    }
                }
            });

            if (mSelectedChildPosition != childPosition && mSelectedGroupPosition != groupPosition) {
                rbut.setChecked(false);
            } else {
                rbut.setChecked(true);
                if (mSelectedRB != null && rbut != mSelectedRB) {
                    mSelectedRB = rbut;

                }
            }
        }

0 个答案:

没有答案