I have a list of items loaded from a web service JSON. Each of these items has it’s own list of sub-items. Each item has numerous text views. The number of subitems varies dynamically, and consists of multiple textviews. There are at times dozens of items with potentially hundreds of subitems. I want all the information visible all the time, i.e. I do not actually need the “expandable” part of the expandable listview but it seemed the easiest way to get the children and group layout.
Item1
sub item 1
sub item 2
Item 2
sub item 1
sub item 2
sub item 3
etc
I have currently implemented an expandable listview and forced the groups to always be expanded. This works, however it is very slow to scroll, not only on the emulator but on my galaxy s2.
I am wondering if there is a better way to achieve this?
I considered a single list view and concatenating the strings in the subitems into a single text view but think that this will not be aesthetically pleasing and I won’t be able to get the layout I want.
I wondered if there is a way to override the listview adapted so that one of the items is an array itself of other items. The adapter could iterate over that array and create new textviews on the fly. I suppose this is what the expandable list view is doing anyway so perhaps this would end up with just as much lag scrolling.
Any help greatly appreciated
You can achieve that with ListView and custom adapter class.
Notice that adapter has methods
int getViewTypeCount()andint getItemViewType(int position)which you can overwrite.look at sample implemation for dataset in Map of lists
and usage example: