0

I have implemented RecycleView similar to ExpandedListView, but when the categories is collapsed(items in category hidden) there are some lags, the reason of it because onBindViewHolder called very fast, for example if category have 20 items and the items hidden onBindViewHolder will be called 20 times in one moment.

There are laggs even if onBindViewHolder is empty

ViewHolders contain less then 5 elements

One solution is to provide list without hidden items, but i wounder how expanded list view works in this situation, because expanded list view receives all items.

Someone familiar with this issue?

Pavel Poley
  • 5,307
  • 4
  • 35
  • 66

1 Answers1

1

You have to create your inner list item's views prior to expand to have a fast expand and collapse. However creating each list again again not a good option because inflating inner items in an action like fling causes glitches. You should use inner recycler views in your items however these recycler views have a special feature. All the inner recycler views depend on the same recycler view pool so once you create list items for an item in outer recycler view, you can use same views in another outer recycler view item. Thus, the system creates for example 10 items for first inner recycler view then when the another inner recycler view is expanded also use same items.

M.ekici
  • 765
  • 4
  • 10
  • Intresting, is it mean that `ExpandableListView` use nested lists views? – Pavel Poley Apr 30 '20 at 18:50
  • Yes actually inner recylerviews but the recyclerviews pick the item views from the same view pool. – M.ekici Apr 30 '20 at 19:00
  • You can look at that question: https://stackoverflow.com/questions/43332873/setrecycledviewpool-method-in-recyclerview to make recycled view pool. – M.ekici Apr 30 '20 at 19:02