androidandroid-layoutlistviewandroid-adaptercustom-adapter

Custom Adapter Where to inflate


I have seen multiple code, where On one hand some inflate in constructor and assign to global variable ,on the other hand ,others inflate in getView() method .

So how the performance changes ,which way is better ?

In first option we have global variable but in second option it will inflate every time getView() called.


Solution

  • ViewHolder Pattern is the best way to implement list view in android. inflate the view for entire device screen and recycle element.