Recyclerview上的单选按钮

时间:2019-02-14 07:32:35

标签: android android-recyclerview android-radiobutton

您好,我在回收站视图中使用单选按钮,但是单选按钮一次选择了多个,并且我知道Google上已经存在代码

private RadioButton lastCheckedRB = null;
...
@Override
public void onBindViewHolder(final CoachListViewHolder holder, final int position) {
   holder.priceRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            RadioButton checked_rb = (RadioButton) group.findViewById(checkedId);
            if (lastCheckedRB != null) {
                lastCheckedRB.setChecked(false);
            }
            //store the clicked radiobutton
            lastCheckedRB = checked_rb;
        }
    });

请解决此问题

0 个答案:

没有答案