CustomListView - A flexible list based on ScrollView

Status
Not open for further replies.

somed3v3loper

Well-Known Member
Licensed User
Longtime User
I am sorry if this question has been answered but does customlistview recycle its elements?
Is it better in handling lots of items than scrollview?
My project has lots of bitmaps.
 

JForge

Member
Licensed User
Longtime User
In my quest to perfect this customlistview I have another question.

Can I make the divider colors different for different activities?
 

JForge

Member
Licensed User
Longtime User
THANKS EREL!

You and this entire community are the absolute best. I am beyond thankful. :)
 

joneden

Active Member
Licensed User
Longtime User
Hi Erel,

I'm using a modified version of this as an autoscrolling list. The issue that I have is that the scrollbar appears on the right and I'd prefer to hide it. Is there a way to use the sv.ScrollPosition without showing the scroll bar?

Regards

Jon
 

socialnetis

Active Member
Licensed User
Longtime User
I have a couple of sections in an app that make use of this listview.
Each sections loads between 20 to 100 bitmaps into the customListView, and I can see an overload of 5-10mb of ram, which I find acceptable.

The problem is that if I go back and forward between these sections, the ram used always increase about 5-10mb each time I enter a section but never goes down. So if I enter the same section 10 times I get about 100mb of ram, and eventually the app crashes with an Out of Memory error.

What is the correct way to avoid this? Maybe saving the panels in a Global variable as List, or this is bad practice?
 

socialnetis

Active Member
Licensed User
Longtime User
Hi Erel, the project is really big and have several "secret" keys to upload.
However, I started recycling the bitmaps in the Activity_Pause and it seems to be working (it recovers about 70-80% of the mb used).
 

Florin

Member
Licensed User
Longtime User
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:

SS-2012-07-15_17.59.22.png


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:
B4X:
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.
 

Florin

Member
Licensed User
Longtime User
"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."

Added CustomView to Designer, Custom Type is not available with CustomListView option.
???
 

Florin

Member
Licensed User
Longtime User
Can you upload your project (File - Export as zip)?
Nope, because : "An error occurred. Object reference not set to an instance of an object" ... ? even if the project runs in AVD and real dev.
 

Florin

Member
Licensed User
Longtime User
Can you manually zip it and upload it?
Where can I find a decent description of CustomListView, such as the ones in basic4ppc.com/android/help ... ? All I could find are posts and examples, not even a link to download the class, had to get it from the CustomListView example ...

UPDATE: Never mind, gave it up.
 
Last edited:
Status
Not open for further replies.
Top