B4A Library [Class] Flexible Table

ardillaprogramadora

Member
Licensed User
You are missing SetHeader and you should invert AddToActivity and InitializeTable.
The code below works:
B4X:
Table2.Initialize(Me, "Table2")
Table2.AddToActivity(Activity, 10dip, 250dip, 300dip, 200dip)
Table2.InitializeTable(2, Gravity.LEFT, False)
Table2.SetHeader(Array As String("Column1", "Column2"))
Table2.AddRowAutomaticWidth(Array As String("msg", "col"))
thanks klaus now it works perfectly!
 

luciano deri

Active Member
Licensed User
Hello, i'am using v 1.44, on a panel on a HorizontalScrollView because i need show some page with more table.
The problem is that HSV consume horizontal swipe event, so table not scroll. But some times, when swiping is diagonal the table scroll. How can i solve it?
(The swipe on header table can is priority on HSW?)
 

klaus

Expert
Licensed User
You cannot use the TableView in a HorizontalScrollView.
Why do you use a HorizontalScrollView?
The TableView scrolls in both directions!
 

klaus

Expert
Licensed User
Unfortunately, the TableView in a HorizontalScrollView will not work.
Because HorizontalScrollView consumes the scrolling event.
 

luciano deri

Active Member
Licensed User
How can i add a sub in Table class to return a event when begin or end swipe touch?
I could try to disable HSW when scroll table and enable when table stop.
 

klaus

Expert
Licensed User
I have nerver tried this, don't know if this will work.
The internal object is a ScrollView2D.
It has a ScrollingIsFinished method.
Perhaps you could use this in the SV_ScrollChanged event routine to raise an event when scrolling is finished.
 

Turbo3

Active Member
Licensed User
What is the purpose of the -/+30 in the ScrollChanged routine which is used to set the currentMin/currentMax?

My users have reported that not all rows of their data are being displayed when I use "Table". The data is loaded from a csv file. I have tracked the problem down to the -/+ 30 preventing the ShowRow routine from being called. If I remove the -/+ 30 offset all the rows are displayed. So why is it there?

B4X:
Private Sub SV_ScrollChanged(PosX As Int, PosY As Int)
    Dim currentMin, currentMax As Int
    currentMin = Max(0, PosY / cRowHeight - 30)
    currentMax = Min(Data.Size - 1, (PosY + SV.Height) / cRowHeight + 30)
 

Turbo3

Active Member
Licensed User
PosY/cRowHeight should give top row number and the other bottom row number on screen but then why the 30 row offset for both?
 

klaus

Expert
Licensed User
It is intendet to limit the number of rows in the scrollview before updating.
Not all rows are added in the scrollview, the rows outsides the given range are dynamically removed and reloaded.
The demo program in the first post loads a Table from a csv file and all rows are shown, so I don't understand why it doesn't in your case.
Can you post a small project showing the problem so I can investigate what happens.

@LucaMs
The 30 without dip is normal !
The value represents an index of a row not a dimension!
 

Turbo3

Active Member
Licensed User
In my case the problem is that the load cvs only displays the first 23 rows (of the 39 rows read in) as that is all that fits on the screen (Addrow limits that). Only the scroll change routine can display the others and you have blocked that with an offset of 30.

Here is the AddRow code.
B4X:
If lastRow < (SV.VerticalScrollPosition + SV.Height) / cRowHeight + 1 Then
           ShowRow(lastRow)
    End If

    SV.Panel.Height = Data.Size * cRowHeight
 
Last edited:

klaus

Expert
Licensed User
Are you sure that bottom part of the scrollview is not hidden by another view or outsides the screen ?
Without seeing your project it is impossible to give a concrete advice.
As already said, the demo program shows all rows, therefore I cannot reproduce the problem.
 

Turbo3

Active Member
Licensed User
I will make up a little demo and post but it is 1 AM here so I will work on it in the morning. But here is the image my user sent me showing the problem when he scrolls down. The bottom should be filled with data but is not. If I remove the "30"s it works.

Log statements show that ShowRow is never called again after the first set of row is loaded.

 

klaus

Expert
Licensed User
You need to be patient, I will be absent till tomorrow afternoon.
It's 9 o'clock AM here.
In the test project ship also your csv file.
 

Turbo3

Active Member
Licensed User
I did a quick test with your latest example code and my user's data and it works. I can scroll down through all his data

However, Log statements show it works because maxVisibleRow is always -1 whereas in my code it is the actual last visible row of 21. It is 21 because that is what fit on the screen when the cvs was first read in.

The question now is why does the example code use -1 when it should use 3 which is all that fits in the much smaller example code window.

More to look at tomorrow. But I should be able to figure this out now.
 

Turbo3

Active Member
Licensed User
After a lot of tracing with Log statements finally found the problem. It is due to Erel's new Resumable Sub feature and my code not being updated to comment out a Sleep(0) statement to prevent the subroutine from being turn into a Resumable.

The table example has the fix for this but my app, which was written years ago and has the Table.bas code that was available at that time, did not have it. I don't actually see the fix listed in the Table version history but is probably mentioned somewhere in the 40 pages of the thread.

In my code the innerClearAll sub was marked as Resumable which was causing parts of it to be executed after the first part of the table was loaded. That caused maxVisibleRow, which had been set correctly, to be cleared.

The fix was to comment out two lines to match the Table example that removed the Sleep(0) statement which is what turned innerClearAll into Resumable. The innerClearAll routine should be executed to the end before any other routines are executed.
 

Inman

Well-Known Member
Licensed User
Is it possible to change background colors of certain rows? In my table, the rows are like grouped into sections. So it will be like:

Section1
Row1
Row2
Row3
Section2
Row1
Row2

I am looking for a way to highlight these section headers so that user knows where a section begins and ends. Is it possible?
 
Top