Search code examples
androidandroid-layoutandroid-listviewgetview

Inflating a view Vs formatting view items


So i have a listview that i want to populate with headers and a view layout with some images and some text.

What is the most performance efficient way to go about this?

Inflate a layout for the header and another for the normal view or use the same layout for both only with some formatting and re-formatting to achieve the goal?

Cheers


Solution

  • If each row will be the same layout format, then it would be better to have one layout that you inflate in your getView() method within the ListView adapter. When this View is inflated, you can than access the TextViews and ImageViews within the layout and configure them to how you would like. I believe that inflating only one view would provide for a quicker and more memory-effecient method.