Android Question ListView vs Scrollview vs memory

wimpie3

Well-Known Member
Licensed User
Longtime User
Let me see if I get this straight.

A ListView can hold thousands of lines because this view removes the invisible rows from memory. Inconvenience: in B4A you can only add an icon and a set of two lines.

A ScrollView can hold all views you want, but scrolling does not remove the views from memory, resulting in out of memory errors if you add a lot of views.

So... how can you scroll vertically in thousands of pictures for instance? Horizontally you can use AHVIEWPAGER, which fires an event you can use to destroy unused views. But VERTICALLY?
 

corwin42

Expert
Licensed User
Longtime User
A ListView can hold thousands of lines because this view removes the invisible rows from memory.
No, thats not true.
So... how can you scroll vertically in thousands of pictures for instance? Horizontally you can use AHVIEWPAGER, which fires an event you can use to destroy unused views. But VERTICALLY?

The only ListView type of object for B4A I know of that can do the things you want is UltimateListView by Informatix. Unfortunately it is not free but it is absolutely worth it's price.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You have three options:
CustomListView, ListView or UltimateListView.

ListView does reuse views and can show 100k rows or more. It is more restricted than the other options. Note that the images are preloaded (unlike UltimateListView).

CustomListView is based on ScrollView. It doesn't reuse views. The advantage of this is that you can completely customize the items. In most cases it is good for up to several thousand items.

UltimateListView is a powerful version of ListView.

Note that there is also TableView / FlexibleTable class which is good for tables. It also reuses views so it supports huge tables.
 
Upvote 0
Top