What is ViewHolder Pattern?

6

I am 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 pattern called ViewHolder Pattern, and my doubts arise exactly at this point.

Questions

  • What is ViewHolder Pattern?
  • What is the purpose of ViewHolder Pattern?
  • What are its benefits?
  • asked by anonymous 17.09.2017 / 17:40

    1 answer

    10
      

    What is ViewHolder Pattern?

    Approach used to store a set of views so they can be efficiently accessed and reused when needed. The purpose of the ViewHolder class is to save the views.

      

    What is the purpose of the ViewHolder Pattern?

    Avoid repeated use of findViewById() to get references to views.
    When saved in a ViewHolder object the references are available immediately.

      

    What are its benefits?

    Avoid loss of performance due to repeated use findViewById() .

        
    17.09.2017 / 19:07