Android: What is the difference between viewholder and viewgroup?

1.7k views Asked by At

please give a detailed explanation about the differences between the viewholder and viewgroup and if they both are similar or used for similar purposes then please tell me the advantages of one over the other.

1

There are 1 answers

1
laalto On BEST ANSWER

They are different things for different purposes.

What they have in common is that they both have references to Views.

A ViewGroup is a parent class of all layouts. It is basically the Composite when applying the composite pattern to create view hierarchies.

A View Holder is not a specific class but just a pattern you can apply to minimize the number of findViewById() calls by caching the results in a holder object. findViewById() is really a DOM tree lookup which is relatively costly in terms of runtime performance.