8
I’m implementing a RecyclerView
on Android and I noticed that it is necessary to create a class called ViewHolder
. This class seems to be a design standard called Viewholder Pattern, and my doubts arise exactly at this point.
Doubts
- What is Viewholder Pattern?
- What is the purpose of the Viewholder Pattern?
- What are your benefits?
A @ramaral question, Butterknife has a similar function that avoids repetition of calling findViewById()... So we can say that he is within this pattern ?
– Dev
@Matheus No. What Butterknife does is generate, for yes, the method calls
findViewById()
. See the main page of Butterknife. There, when referred to the Viewholder standard, it is said that it "simplifies", which is different from replacing.– ramaral
@ramaral, speaking of Butterknife, using the Viewholder standard on an Activity, and passing it as a parameter to an auxiliary class, is it bad practice regarding efficiency? or would it be better to pass the objects on themselves? or it would be even better to do everything you have to do in the views within Activity itself (whether to use viewholder or not)?
– Guilherme Ramos
@GR_ I’m sorry but I can’t understand what you’re asking, perhaps due to lack of context. What do you mean, "use the Viewholder pattern in an Activity"?
– ramaral
@ramaral I’ll create a question and leave the link here for you to understand. I find it easier to explain everything in a haha comment
– Guilherme Ramos
@ramaral https://answall.com/q/270541/4306
– Guilherme Ramos