How to Select Just One Radiobutton With Recyclerview Android

Select only one radiobutton in a recyclerview

Here is another method to do the same. This is more elegant than my previous answer. But I have kept both as the previous answer provides more flexibility.

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

Single selection in RecyclerView

The solution for the issue:

public class yourRecyclerViewAdapter extends RecyclerView.Adapter<yourRecyclerViewAdapter.yourViewHolder> {

private static CheckBox lastChecked = null;
private static int lastCheckedPos = 0;

public void onBindViewHolder(ViewHolder holder, final int position) {

holder.checkBox.setTag(new Integer(position));

//for default check in first item
if(position == 0 && fonts.get(0).isSelected() && holder.checkBox.isChecked())
lastChecked = holder.checkBox;
lastCheckedPos = 0;

holder.checkBox.setOnClickListener(new View.OnClickListener()
public void onClick(View v)
CheckBox cb = (CheckBox)v;
int clickedPos = ((Integer)cb.getTag()).intValue();

if(lastChecked != null)

lastChecked = cb;
lastCheckedPos = clickedPos;
lastChecked = null;


Single choice Radion Button in Recycler view (Duplicate)

Add your onCheckedChnageListener() in your onBindViewHolder() method and maintain your mSelectedItem inside the onCheckedChnageListener()

 viewHolder.rdCategoryItem.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

How to select one radio button from radiogroup in a RecylcerView in android?

Use an interface as a listener of radio button click.

public interface AnswerSelectedListener {
void answerSelected(String answer);

Add an AnswerSelectedListener class attribute to your DailyQuestionModel class and constructor & Pass an implementation of this interface to each of your DailyQuestionModel:

questionList.add(new DailyQuestionModel(
new AnswerSelectedListener() {
public void answerSelected(String answer) {
//Here you have the selected answer to question 01

Inside you RecyclerView adapter, call this listener when an answer is selected:

public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
final DailyQuestionModel model = questionList.get(position);
String question = model.getQuestion();
answers.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
public void onCheckedChanged(RadioGroup group, int checkedId) {
RadioButton checkedRadioButton = (RadioButton)group.findViewById(checkedId);
boolean isChecked = checkedRadioButton.isChecked();
if (isChecked) {

This code is not tested but I think it gives the overall flow.

android - Single RadioButton in RecyclerView

You can manage it by creating a model class with a boolean variable isChecked.

when you select a RadioButton first do isChecked = false for all and then make true for your selected button and then call notifyDataSetChanged.

In adapter use


It will help you definitely.

Related Topics

Leave a reply