Reputation: 819
I have list of data and i want to select only one from it. I have radiobutton and textview in my adapter. Using notifyDataSetChanged() I am getting single selection but on scroll radio button's value set to "false" and my previous selection is not in same state(true).
Any code or link.
Upvotes: 1
Views: 4010
Reputation: 26831
You need to save state on your model object which you are inflating in each row of RecyclerView. Then in the bindViewHolder(MyViewHolder myViewHolder, int position)
method, you can conditionally set checked state of your radio button like this:
myViewHolder.radioButton.setChecked(myModel.isSelected());
Upvotes: 1