Issue
When I check a box and in recycler view auto-checked after 11- 12 item. I didn’t even clicked that checkbox here is the code.
I think this issue is in holder with the position so I’m only providing holder code because it’s confidential.
Adapter holder code:
inner class ProductListViewHolder(val itemBinding: SelectProductLayoutBinding) :
RecyclerView.ViewHolder(itemBinding.root) {
fun bindItems(data: ManufacturingProductItem, position: Int) {
if (data.name != null)
itemBinding.userNameTv.text = data.name
else
itemBinding.userNameTv.text = ""
itemBinding.userNameTv.setOnClickListener {
listener.onProductClickListener(
data,
itemBinding.userNameTv.isChecked
)
}
}
}
in belove code about pagination of recycler view kindly understand please
binding.productRv.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
super.onScrollStateChanged(recyclerView, newState)
if (newState != RecyclerView.SCROLL_STATE_IDLE) {
return
}
if (!recyclerView.canScrollVertically(1)) {
if (productAdapter.getProductResponseList.size > 2) {
count++
productPresenter.getProducts("", count.toString(), true)
}
}
}
})
Solution
I found the solution of this problem
It simply need these function to implement
override fun getItemId(position: Int): Long {
return position.toLong()
}
override fun getItemViewType(position: Int): Int {
return position
}
Answered By – mujammil soft
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0