B4A Library [Class] TableView - Supports tables of any size

An improved version of this class is available here: http://www.b4x.com/forum/additional...icial-updates/30649-class-flexible-table.html


The Table class allows you to show tables of any sizes. The views (labels) are reused to avoid creating many views.

With the help of StringUtils the table can be loaded and saved to a CSV file. It shouldn't be difficult to show SQL tables using DBUtils.ExecuteMemoryTable.

SS-2012-07-04_10.38.01.png


Follow the attached example to see how the class is used. To add it to your own project you need to add the class module to your project and add a reference to StringUtils library.

RemoveRow code is available here: http://www.b4x.com/forum/showpost.php?p=146795&postcount=147

V1.10 uploaded. New method: SetColumnsWidths. Allows you to manually set the width of each column
V1.11 uploaded. Fixes a bug with grey stripes appearing.
 

Attachments

  • Table.zip
    14.9 KB · Views: 7,617
Last edited:

Mahares

Expert
Licensed User
Longtime User
I'm getting gray bars within the bottom table.

If you take a look at my post #23 for image and my post #36, I discuss it and offer my findings. In summary, I tested with 2 devices with OS 4.0 where the gray bars appeared, but when I tested with a device with OS2.2, there are no verical gray bars. There is nothing wrong with Klaus's code. Perhaps, Erel or Klaus with their broad knoweledge can figure out a solution to the OS.
 

Mahares

Expert
Licensed User
Longtime User
@Klaus: Yes, I tested the new version you posted 1.10_2d and it exhibited the same exact behavior. Gray bars with ICS4 and no gray bars with OS2.2.
Merci infiniment.
 

klaus

Expert
Licensed User
Longtime User
Can you please test the attached version ?
It's Erels' version with a seekbar to scroll horizontally the upper table.
The goal is to see if the problem could come from ScrollView2, the attached version uses a standard vertical ScrollView.

Best regards.
 

Attachments

  • TableSeekbar.zip
    15.1 KB · Views: 378

Informatix

Expert
Licensed User
Longtime User
Can you please test the attached version ?
It's Erels' version with a seekbar to scroll horizontally the upper table.
The goal is to see if the problem could come from ScrollView2, the attached version uses a standard vertical ScrollView.

Best regards.

I can't see the relationship. :confused:
ScrollView2D and ScrollView are designed to handle the scrolling of an inner panel, nothing more. They have only one child: this inner panel, which is a separate object in a separate library. If you put other views in this panel, that does not concern at all the ScrollView library (it does not even know they exist, except when it sets focus).
 

Mahares

Expert
Licensed User
Longtime User
@Klaus: I tested the TableSeekBar.zip sample. Here are my findings:
1. On a phone with ICS4.0, the gray bar shows up in the top table even before moving the seekbar. The bar does not appear in the bottom table because all columns have the same width.
2. On a 7 inch table running Froyo2.2. There are no gray bars in either table.
 

klaus

Expert
Licensed User
Longtime User
@Erel,
After Informatixs' advice I installed an Android 4.1 Emulator and got the gray lines.
I had a closer look at the class and found that the problem comes from the label background setting.
Instead of setting lbl.Background = ColorDrawable
I set lbl.Color = Color.
And the grey lines disappear.
It seems that when changing the width of the labels to a bigger one the Background object keeps the previous width and doesn't update it.

Attached a new version of TableExample1.21_2D

Best regards.
 

Attachments

  • TableExampleV1_21_2D.zip
    15.1 KB · Views: 376

Gravy Jones

Member
Licensed User
Longtime User
Cell Spanning

I compiled and ran the program on my Kindle Fire and it is very nice. I work with Spreadsheets and I see that it would be greatly useful to span cells with this class. It would be great if cells could be spanned horizontally and vertically. The upper left cell is what gets displayed. Is something like this possible? Excel spans cells by using the merge cell formatting

properties.:sign0098:
 

Mahares

Expert
Licensed User
Longtime User
What about keeping the first column or two stationary (locked) while scrolling left or right?. It will make it easier to identify the records.
Thank you
 

Mahares

Expert
Licensed User
Longtime User
In order to keep the first column (locked) while scrolling left or right,
I tried to create a panel with a listview and load it with the first column data of the table and place it on the left of the table itself, but unfortunately, I could not synchronize the vertical scrolling of the listview and the table itself. Any help is highly sought. Please see my code snippet for creating the stationay column below:

B4X:
Dim Mylv As ListView
Dim MyPanel As Panel
MyPanel.Initialize("MyPanel")
Mylv.Initialize("Mylv")
MyPanel.AddView(Mylv,0, 10%x, 180dip, 35%y)  
Mylv.SingleLineLayout.ItemHeight=35dip 
Mylv.SingleLineLayout.Label.TextSize = 14      
'Mylv.FastScrollEnabled=True 
Activity.AddView(MyPanel,0, 10%x, 180dip, 35%y)

txt = "SELECT F1 FROM MyTable ORDER BY F1 " 
Cursor1=SQL1.ExecQuery(txt) 
Cursor1.Position=0
For i=0 To Cursor1.RowCount-1
   Cursor1.Position=i
   Mylv.AddSingleLine(Cursor1.GetString("F1"))
Next
Cursor1.Close
MyPanel.BringToFront
 
Top