
when these items could potentially become. in android development, developers usually have to handle some sort of selection from a list of items. Android: handling checkbox state in recycler views. this file will hold the information of every item which you want to show in your recyclerview. name that file as itemsviewmodel and then click on ok.

go to app > java > package name > right click > new > kotlin class file and choose data class from the list. class usercategoryadapter (private var data: list, private var listener: (kategori) > unit) : recyclerview.adapter () then in your bind you send the listener via constructor as well. To use a listener you need to add invoke, so the flow should be : your adapter declaration. MyRadioGroup.Android Recyclerview With Checkbox Kotlin Youtube If (myTask.isDone) myRadioGroup.Check(Resource.Id.rbDone) Įlse myRadioGroup.Check(Resource.Id.rbNotDone) where myTask is a basic class with a done boolean isDone check which radioButton should be selected within each group MyRadioGroup.CheckedChange -= doSelectionChanged It turns out that in my GetView that I was checking if the item should be checked, and this was firing the CheckedChange event.īy simply de-registering the CheckedChange event in the GetView, then checking if the item should be checked, then adding the CheckedChange event, this solved the issue:

Selecting the first item in the first group was fine, but when I scrolled down the screen, the CheckedChange event fired again and again as the view was recycled. I have a ListView with an Adaptor which has a RadioGroup. If anyone else comes up with this issue: I have just spent a day on it.

List View Adapter: internal class SomeListViewAdapter : BaseAdapter, IFilterable įeel free to ask me a questions about this. The weird behavior I'm getting is that when I check a checkbox and scroll up and down in the ListView, other checkboxes randomly get checked/unchecked by themselves. The View has has a checkbox and a textview.
