I’m working on an android application and I have run into a decision that I can’t decide on one way or another. I was hoping someone could shed some light on the common practices and any theory to back them.
Here’s the issue:
I want to have a list of items with images and text like table…
Country -.-.-.-.-.-.- Pop -.- SqrMi
[img] US -.-.-.-.-.-.- xxx -.-.- xxxxx
Now the debate I’m having is whether or not to use a listview to display the data or instead nest a layout that is scrollable and just display the data that way.
Why would I even consider a nested layout? Flexibility. I can design the dividers, possibly throw in a couple graphs above/below the list. Vary the height of each of the list items (like what if I want to show a graph in one list item and no graph in the next), etc.
I’m not sure if I’m breaking the generally accepted methods here. Can anyone shed some light on this?
The only major problem you will have when using nested layouts is memory consumption.
ListViewreuses its children so it doesn’t create more children then it can display at a single moment. This description is a little simplified but I hope it shows the purpose of theListView. AlsoListViewimplements its own fast scrolling so it doesn’t have to measure all its children to determine its size. AndListViews use adapters to populate themselves with data. It’s a nice and convenient way to obtain data.On the other hand if you create a
ScrollViewwith a lot of views inside it’ll be slow, difficult to populate with data and it’ll require a lot of memory to create all of the child views even if you don’t ever see some of them.And about flexibility of the
ListView. You can store different types of view in a singleListViewand you’ll be able to vary the height of each of this views.