The native ListView is a optimized for very large lists. Instead of creating the views for each item, it reuses the same views when possible. This optimization makes it very difficult to customize the items.
CustomListView is an implementation of a list based on ScrollView.
CustomListView is suited for lists of up to 1000 or 2000 items.
Advantages of CustomListView:
- Each item is made of a Panel that can hold any views.
- Items can be modified at any time.
- It is possible to insert or remove items from any position.
- Each item can have a different height.
- Items height can be set automatically based on the text (using AddTextItem).
Using CustomListView is simple:
- First you should initialize the list and add it to a panel or activity.
- Then you should add items.
Each item is made of a panel that holds other views.
AddTextItem is a convenient utility to add items made of a single label.
The attached example creates two lists:
The first list is made of simple text items.
In the second list each item is made of a label, button and checkbox.
All the buttons are handled by Sub Button_Click.
The clicked item is found by calling:
index = clv2.GetItemFromView(Sender)
This class depends on the Reflection and StringUtils libraries.
V1.10 - Adds designer support. CustomListView can now be added with the visual designer. Add a CustomView and then set its CustomType property to CustomListView.