Android-Image-Slider icon indicating copy to clipboard operation
Android-Image-Slider copied to clipboard

onBindViewHolder is called causing wrong pages

Open ghost opened this issue 5 years ago • 0 comments

onBindViewHolder is called when go from the first page to the last.

To Reproduce Scroll the pages until the onCreateViewHolder is called and the new page appear

Expected behavior Should not create a new page and use the one already created

Additional context I'm in hurry for a project soo to correct this problem I override the instantiateItem

@NonNull @Override public Object instantiateItem(@NonNull ViewGroup container, int position) { if(created[position] == null){ created[position] = onCreateViewHolder(container); }else{ super.destroyItem(container, position, created[position]); created[position] = onCreateViewHolder(container); } container.addView(created[position].itemView); onBindViewHolder(created[position], position); return created[position]; } // where created is an array of VH

Doing so the old page is destroied, but should not create a new one in the first time

ghost avatar Jul 04 '20 17:07 ghost