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.
They are different things for different purposes.
What they have in common is that they both have references to View
s.
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.