2

I'm using FlexboxLayoutManager in RecyclerView and I need to prevent RV from recycling. I tried to set itemViewCacheSize() to total items count, but it didn't help. Also I tried to set maxedRecycledViews() to 0 with no result. How can I prevent RV from recycling?

BorisTheCoder
  • 81
  • 1
  • 5
  • 1
    "I need to prevent RV from recycling" -- then do not use `RecyclerView`. Why would you want to use `RecyclerView` without recycling views? Perhaps there is some other solution to whatever problem you are experiencing. – CommonsWare Mar 14 '17 at 19:03
  • 2
    @CommonsWare I need `RecyclerView` for it's drag and drop feature. In plane `FlexboxLayout` drag and drop doesn't work like in `RecyclerView` – BorisTheCoder Mar 14 '17 at 19:11
  • Possible duplicate of [I want my RecyclerView to don't recycle some items](http://stackoverflow.com/questions/36313079/i-want-my-recyclerview-to-dont-recycle-some-items) – stamanuel Mar 14 '17 at 19:15
  • `RecyclerView` does not have a drag-and-drop feature AFAIK. Drag-and-drop can be implemented using a `RecyclerView`, but that's not built in. If `FlexboxLayout` is preventing you from implementing drag-and-drop in a `RecyclerView`, file a bug with the flexbox project, or do not use `FlexboxLayout`. Using `RecyclerView` properly, including recycling views, is **much** more important than is using `FlexboxLayout`, IMHO. – CommonsWare Mar 14 '17 at 19:18
  • 1
    @CommonsWare in my project i need to build grid of `TextureViews` with videos in it. Also i need to change grid configuration (which include resizing) without reloading videos. I can achieve than by setting `LayoutParams` to each child of `RecyclerView` or `FlexboxLayout` without `RecyclerView`. But when i'm scrolling my items in `RecyclerView`, videos are starting to reload. That's why i need either increase recycle pool of prevent `RecyclerView` from recycling at all – BorisTheCoder Mar 14 '17 at 19:28

1 Answers1

4

Call setIsRecyclable(false) under onBindViewHolder.

override fun onBindViewHolder(holder: ManşetViewHolder, position: Int) {
    holder.setIsRecyclable(false)
}
Salih
  • 171
  • 1
  • 12