Android-Image-Slider
Android-Image-Slider copied to clipboard
onBindViewHolder is called causing wrong pages
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