I have a nested RecycleView:
BodyRecycleView has each item is a DetailRecycleView
DetailRecycleView has each item is a element
elements in DetailRecycleView only shows when it’s touched
I think about saving time at creating step of BodyRecycleView so I skip creating dataset of elements in DetailRecycleView.
onBindViewHolder()
of BodyRecycleView only create DetailRecycleView with an empty dataset.
Dataset of elements in DetailRecycleView is created in
getItemCount()
of DetailRecycleView. It doesn’t have problem in display but when touching on element to interact with, it sometimes it shows wrong element.
I tried to debug and found that when issue happen, it doesn’t call
onCreateViewHolder()
of element has problem. In normal situation, it should call like this:
onCreateViewHolder()
ViewHolder constructor
onBindViewHolder()
ViewHolder constructor
and
onBindViewHolder()
hasn’t been called so it shows element in other DetailRecycleView;
Maybe put initialization of dataset in
getItemCount()
makes this problem. Is there any way to keep my approaching and pass this situation?