Your code can often call findViewById() while scrolling through a ListView , which can slow performance. Even when the adapter returns an inflated view for recycling, you still need to look for items and update them. The way to reuse findViewById() is to use the "view holder" template.
An object
A ViewHolder stores each of the component views inside the layout tag field, so you can immediately access them without having to re-review them. First, you need to create a class to hold your exact set of views.
Learn more about the Android Guideline .
- Therefore, when you use the "View Holder", you can easily access each view without the need for a search, which saves valuable processor cycles.
- with
static inner class for views significantly improves performance
You can also see why Android prefers static classes .
Another interesting link How ListView works , after reading this blog, the developer can clear the LisView logic, and why you need to implement an internal static class for listView.
Vivek Kumar Srivastava
source share