FVod FVod - 23 days ago 19
Android Question

Avoid reusing item on recyclerview

I have a recycler view which is reusing view, my problem is that one viewholder contains a ViewPager and, if the recyclerview's adapter reuse the view where the viewholder is inflated then an exception occurs on the viewpager.
However, the onCreateViewHolder method is only called the first time. How could I avoid this behaviour and achieve that the onCreateViewHolder can be called more than once?

Thanks in advance

Answer

use recyclerView.getRecycledViewPool().setMaxRecycledViews(YOUR_VIEW_TYPE, 0); This will disable recycling of the specified view type

Comments