*Note: There are solutions for this issue in stackoverflow but all are written in java
In Recyclerview implemented checkbox OnCheckedChangeListener as follows, problem is when i scroll recyclerview then random checkbox is selected.
override fun onBindViewHolder(holder: PickListViewHolder, position: Int) {
holder.cbSelected.setOnCheckedChangeListener { buttonView, isChecked ->
if (isChecked) {
selectedSerialNumberList.add(this.scSerialNumberList[position])
} else {
selectedSerialNumberList.remove(this.scSerialNumberList[position])
}
}
}
inner class PickListViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView),
View.OnClickListener {
val cbSelected: CheckBox = itemView.cb_selected
}
Aucun commentaire:
Enregistrer un commentaire