Loading large tables (grids)

prokli

Active Member
Licensed User
Longtime User
Hi everybody.

I created a table based on a vertical scrollview and a number of labels which are added to this scrollview at runtime. Each row keeps 31 labels
This works excellent till number of rows exceeds a value of about 300. In this case Android OS stops my application (obviously caused by a timeout). I tried to insert some "DoEvent" statements while creating this large table. But same problem comes up when the number of rows exceeds 400 - 450 rows.

I know, that there exists a "Threading Library" which lets run Sub's as separate thread (outside GUI). But how to realize large grid tables inside such a thread? I always need to access the GUI thread while building such a grid table and threads doesn't allow such an access?

Someone any idea??

Thx
 

mc73

Well-Known Member
Licensed User
Longtime User
In some of my apps I have scrollviews for populating db data, but when it comes to large amount, I always try to use a listview instead. I know nothing about the cause of the problem you have, but couldn't it be easier to use a listview? just an idea...
 
Upvote 0

prokli

Active Member
Licensed User
Longtime User
I don't think that a listview will help.
Listview's do not provide the capability to add other views (like labels).
Using a listview I would have two grids (plus one for a bitmap), but I need 31 items per table.

Thanks for your kind reply!
 
Upvote 0

prokli

Active Member
Licensed User
Longtime User
In the meantime I changed my code and let a timer load the table step by step.
First I had to find out the number of labels which could be loaded to a panel till OS stops my app. It's somewhat "fine tuning".

Now I noticed that I get a "out of memory" error. :sign0161:
I guess that I am trying to put too much labels to a panel.

Have I reached any limits of B4A??
 
Upvote 0

prokli

Active Member
Licensed User
Longtime User
Thanks!
Does this mean that there is a maximum number of views which I can add to a panel or activity in Android?
What to do if I need large tables?
Thx
 
Upvote 0

prokli

Active Member
Licensed User
Longtime User
No!
I am just loading labels to a panel (accordingly to the table examples as provided by you and Klaus).

I keep two activities:
The first activities loads a table of 600 rows x 12 Columns (works!)
The second activity loads a table of 600 rows x 31 Columns (OS stops working)
First activitiy is paused when starting second one (but I suppose its data remains still allocated)
I notice that loading the second table gets slower and slower over time ( I use a timer to build both tables).
 
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
How are you populating the Panels with the Labels.
Are you sure that when you populate a panel a second time you are not adding all the labels to the existing ones. In that case you must remove the existing views before populating.
If we could have a look at your code we could see if this is the case.
You should set a Log at the beginning showing the number of views in the panel. If it increases every time that means you are adding the labels.

Best regards.
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
I replicated the problem. Indeed when trying to set too many data, android OS misbehaves. I see a small app runining over 17 mb of usage, leading the os to red flag.
I then tried to replace scrollview with a webview loading a html table. Creating the html file, didn't seem to cause problems. BUT when I viewed it inside the webview, it was finishing in row 90 (columns 100), even if the previous routine did create a html table with a 1000 rows.
Anyway, when I think about it calmly, I cannot avoid but asking myself: who would actually need to browse that many rows? We can always set the view to hold 10-20 rows and then user browse using pageUP/DN buttons, can't we?
 
Upvote 0

prokli

Active Member
Licensed User
Longtime User
Klaus,

first of all, thanks for giving me some good ideas!
There are two different scrollviews located on two different activities.
Starting first activity loads labels on first scrollview's panel (exactly the code as provided by you!)

SV.Initialize(0)
SV.Panel.Color=Colors.White
Table = SV.Panel
Table.Color = Colors.DarkGray
Activity.AddView(SV, 0%x, 10%y, 100%x,82%y)
ColumnFactor = SV.Width / 100 '1% of scrollview width
........
.......

Sub AddRow(Values() As String, cRow As Int)As Boolean
'NumberOfColumns = 12 on first table
For i = 0 To NumberOfColumns - 1

Dim L As Label
L.Initialize("cell")
L.Text = Values(i)
L.TextSize = FontSize
L.TextColor = FontColor
L.Color=Colors.White
Dim rc As RowCol
rc.Initialize
rc.Col = i
rc.Row = cRow
L.Tag = rc
cellWidth = ColumnWidth * ColumnFactor - ColLineWidth
Table.AddView(L, lpSum, RowHeight * cRow, cellWidth, RowHeight_1)
lpSum = lpSum + cellWidth + ColLineWidth
Next
Return True

End Sub

Starting the second activity does exactly the same (whereas first activity is not closed by an activity.finish statement).
What I found out is: as long as I load only a few rows (200) on first table and also on the second table everything works fine. Problems are coming up when I use to much rows on the second label (> 300 rows). I Am sure that I do not overload existing views. When starting these activities I call "ClearAll( )" which runs through activity's views and removes them.

Nevertheless, I am not sure if my code includes some mistakes.
I will do a short example based on your code (but with much more rows) and see what happens.
 
Upvote 0

prokli

Active Member
Licensed User
Longtime User
@mc73:
Who need such large tables? Good question!
People like me, who want to export the main features of MS Project to Android. This might sound ridiculous but it seems possible.
I suppose users of MS Project will become bored when scrolling through a 200-lines project pressing a continue button every 20 lines. Don't you agree?
 
Last edited:
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
By MS project, you mean something like excel?
 
Upvote 0

prokli

Active Member
Licensed User
Longtime User
No, I really mean MS Project including entire task management as you might know from MS project (dealing with costs, work, resources, dates, successor task and a lot more…).
Once again:
I can load a large project keeping up to 600 tasks inside my first table. As soon as I start a second activity keeping a second table (which I need to show further information), Android times out after about 320 lines ( I don't get a code error, I just get the message "Sorry application is going to be closed"..)

Uff…hard work!
:BangHead:
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User

Ok, have a look at the attached sample. I'm using a webview which handles 1000x50 grid. In case it fits your need, you can then create a more efficient html with setting tags in every cell in order to edit by using override_url or even javascript.
 

Attachments

  • largewebview.zip
    6.6 KB · Views: 268
Upvote 0

prokli

Active Member
Licensed User
Longtime User
Thanks a lot!
I will check how I can this code integrate to my app.
:sign0098:
Cheers!
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I modified the TableExample1.2zip program to generate a 31 column table and noticed that it can generatea, on my Nexus One, a bit more than 600 records but when trying to generate 700 records the program stops 'unexpectedly'.

Best regards.
 

Attachments

  • TableExampleHugeNumber.zip
    13.3 KB · Views: 268
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…