FVod FVod - 1 year ago 174
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 Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download