Reputation: 2457
I have an application that lets you flip through cards in a deck.
Would it be better to reuse maybe 2-3 views(cards) and just change the text/image on them.
Or should i recreate(inflate) a new view(card) each time?
Performance wise which is better?
Upvotes: 0
Views: 106
Reputation: 93561
Reusing is always better performance wise. Think about it- if you create new ones, you have to create these large objects, then set values to various properties. If you reuse, you just set the values. Creation is a superset of the work you do or reuse. If you want to see the difference, create a relatively complex ListView. Run it with full recycling. Then run it where you create a new View for each getView call. That performance difference is due to creation.
Now the question is if its enough of a bonus to be worth doing. If the number of subviews is small enough, maybe not. As the complexity of the views and the number of them increase, then it is.
Upvotes: 1