Selecting one RadioButton value and scrolling back removing the selected one in RecyclerView

后端 未结 9 1886
温柔的废话
温柔的废话 2020-12-15 18:24

In my application am displaying 20 multiple choice questions with the help of RecyclerView.

If I change the value of first RadioGroup and s

9条回答
  •  萌比男神i
    2020-12-15 18:49

    Inside your student class add a boolean variable isSelected. Now on checkedChangeListener of each radiogroup, change the value of isSelected to mark whether some value has been selected or no selection has been made. Now inside onBindViewHolder() just do

        if(stList.get(position).isSelected){
      viewHolder.rgAnswers.check(stList.get(position).getSelectedRadioButtonId());
        }else{
        viewHolder.rgAnswers.clearCheck();
        }
    

    At the end you can iterate over the whole list and check for which objects, isSelected is true

提交回复
热议问题