1

I have some compound components that are used as my ListView items. To increase the performance I use view holder to render my ListView item but as each one has a compound component inside, it is still slow and rendering each compound component requires inflating the component each time.

Is there any way that I can use something like ViewHolder pattern for my compound component?

loshkin
  • 1,600
  • 2
  • 21
  • 38
hasan
  • 966
  • 2
  • 13
  • 40
  • Viewholder pattern is use to keep a reference to views so you do not have to perform findViewById() everytime you want to bind your data to view. It got nothing to do with inflating views. – Weizhi Nov 03 '16 at 10:24
  • Use RecyclerView that reuses the ViewHolders instead of the ListView. Reduce the nesting of Views (Use can use ConstraintLayout for the compound views). If you have images that you load into the compound views load them with Picasso because it will downsample them before loading them into memory. – loshkin Nov 03 '16 at 10:52

1 Answers1

0

For ListView a good performance enhancement is using getTag() and setTag() methods to retain the views defined in a viewholder. Then the views are not created again and reused in which you can just change content then.

Besides this, RecyclerView is always a better choice.

Ref :-

  1. (RecyclerView vs. ListView)
  2. (What is the working of setTag and getTag in ViewHolder pattern?)
Community
  • 1
  • 1
Gaurav Chauhan
  • 376
  • 3
  • 14