I have a nested recycler view, which basically looks like a card view and a check list inside the card view, Now the issue i am facing is that when i close my app and reopen it.It starts displaying the list which is in the first card View to every other Card View inside my recycler View, to stop this i have used setIsRecyclable(false) inside my child adapter, but it isn't working and i keep facing the issue. How can i change my implementation? I am using an observer to update my child adapter.
Code Inside my OnBindViewHolder for child adapter
holder.setIsRecyclable(false)
holder.itemView.check_box_completed.isChecked = getItem(position).completed
holder.itemView.text_view_name.text = getItem(position).name
holder.itemView.text_view_name.paint.isStrikeThruText = getItem(position).completed
Log.d("TAG1", "Inside: ${getItem(position)}")
holder.itemView.check_box_completed.setOnCheckedChangeListener { checkBox, isChecked ->
if (isChecked) {
mainViewModel.updateListItem(
TaskList(
getItem(position).name,
isChecked,
getItem(position).Taskid,
getItem(position).taskNoteId
)
)
} else {
mainViewModel.updateListItem(
TaskList(
getItem(position).name,
isChecked,
getItem(position).Taskid,
getItem(position).taskNoteId
)
)
}
}
Please do not spend time on stopping recycler view from recycling views.
Instead, I would request you to change your design.
Recycler View
itself is a big functionality and should be managed separately from other views.
By that I mean is, please do not nest Recycler View deep inside other views.
Try too keep the design simple of your app. This will be easy for you as a developer to maintain the code and also add new features in future.
I understand that you need to have Card Views
in your UI, however, please try to see if you can move the 'Card View' to separate fragment/activity. Adding an extra screen to reduce complexity in design is always acceptable.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.