Dynamically, i have added multiple options under one question in recycleview. Now a user can select one option inside each questions.Look at the below image,
Recyclerview Adapter
class is,
@Override
public void onBindViewHolder(final MyViewHolder holder,int position) {
final PollQstWithAns poll = dataList.get(position);
holder.txt_poll_question.setText(poll.getPollQstName());
for (int i = 0; i < poll.getOptionList().size(); i++) {
final PollsData mPollsOptionsList = poll.getOptionList().get(i);
final RadioButton rb = new RadioButton(context);
rb.setText(mPollsOptionsList.getAns1());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ColorStateList colorStateList = new ColorStateList(
new int[][]{
new int[]{-android.R.attr.state_enabled},
new int[]{android.R.attr.state_enabled}
},
new int[]{
Color.DKGRAY
, ContextCompat.getColor(context, R.color.colorPrimary)
}
);
rb.setButtonTintList(colorStateList);
rb.invalidate();
rb.setTextColor(ContextCompat.getColor(context, R.color.gray));
}
holder.optionRadioGroup.addView(rb);
}
}
I want to get all checked values from each questions, if user select the RadioButton
inside the RadioGroup
.