1

I know how to populate a ListView or any other list types, but now I am facing an issue where I should implement a ListView in a ScrollView. So, I decided to use a LinearLayout ( myLinearLayout.addView( adapter.getView(position, null, null) ). As you can see, I am retrieving data from adapter and adding as a new view to my LinearLayout. Everything is working, but if the list is being populated with 30+ rows the application freezes. Each row contains an ImageView and this way the virtual machine can't allocate enough memory.

How I should recycle linearlayout rows?

Zbarcea Christian
  • 9,367
  • 22
  • 84
  • 137

2 Answers2

0

It doesn't look like a good idea to put a listview inside a scrollview. How are your users gonna use that ? Which gesture will scroll the scrollview and which one will scroll the listview ? It's not going to be usable.

Android components are well designed, you should really consider sticking to a listview that every one knows how to use and is pretty well optimized.

If you have troubles displaying many images in a list, refer this docs from google.

Snicolas
  • 37,840
  • 15
  • 114
  • 173
0

Once you populate the row into a linear layout the views aren't recycled by the adapter. As you wrote its also not possible to have to scroll components one inside the other. Why do you need to show list inside scroll? Did you considered populate the list "on top" of the scroll view? For example in a different fragment?