There is one simple question which after searching i wanted to ask that why we create static holder class and assign the views inside it?? Please clear my doubts it will be great help to me.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your code might call
findViewById()frequently during the scrolling ofListView, which can slow down performance. Even when the Adapter returns an inflated view for recycling, you still need to look up the elements and update them. A way around repeated use offindViewById()is to use the"view holder"design pattern.A
ViewHolderobject stores each of the component views inside the tag field of the Layout, so you can immediately access them without the need to look them up repeatedly. First, you need to create a class to hold your exact set of views.You can read Android Guideline for more detail.
static inner classfor the views greatly improves performanceyou can also see Why does Android prefer static classes link.
One more interesting link How ListView Work, after reading this blog developer can clear logic of LisView and also why need to implement inner static class for listView.