B4i Library [class] Table

Status
Not open for further replies.
B4i implementation of TableView: http://www.b4x.com/android/forum/threads/19254/#content

SS-2014-11-06_16.45.33.png


TableView can show a huge number of items as it reuses the labels. Note that in debug mode the scrolling is a bit jumpy. It scrolls perfect in Release mode.
 

Attachments

  • Table.zip
    10.3 KB · Views: 485
Last edited:

fishwolf

Well-Known Member
Licensed User
Longtime User
I use this module with success, but when i enter the second time into page with table, the design table is corrupt.

In this case i had add a table to ThreePage example (note to top a part of table)

B4X:
Public Sub ShowModule
   If pg.IsInitialized = False Then
     pg.Initialize("pg")
     pg.RootPanel.LoadLayout("ColorsLayout")
     Dim items As List
     items.Initialize
     For Each clr As String In clrs.Keys
       Dim s As AttributedString
       s.Initialize(clr, Font.DEFAULT, clrs.Get(clr))
       items.Add(s)
     Next
     Picker1.SetItems(0, items)
   End If
   Main.NavControl.ShowPage(pg)
   btnChoose.Color = GetSelectedColor
   
   TableResults.Initialize(Me, "TableResults", 7)
   TableResults.AddToParent(pg.RootPanel, 0, 50%y, 100%x, 50%y)
   TableResults.SetHeader(Array As String("Data", "Prove", "Arr", "Tp", "E/R", "Pen", "Qual"))
   
   For i = 0 To 100
     TableResults.AddRow(Array As String("Row: " & i, "ccc", "ddd", "eee", "ccc", "ddd", "eee"))
   Next
   
End Sub
 

Attachments

  • foto.PNG
    foto.PNG
    172.7 KB · Views: 211

Turbo3

Active Member
Licensed User
Longtime User
How hard is it to add the ability to scroll left/right to display a large table (wide) like the B4A version?
 
Last edited:

klaus

Expert
Licensed User
Longtime User
Here you are.
Attached version 1.11
Added horizontal scrolling.
Added Left, Top, Width, Height, Visible properties
Added LoadTableFromCSV2(Dir As String, Filename As String, HeadersExist As Boolean, SeparatorChar As String, AutomaticWidths As Boolean)

EDIT: 2015.10.13 version 1.12
Amended errror reported HERE.
 

Attachments

  • TableViewV1_10.zip
    12.1 KB · Views: 66
  • TableViewV1_11.zip
    12.2 KB · Views: 72
  • TableViewV1_12.zip
    12.2 KB · Views: 160
Last edited:

Turbo3

Active Member
Licensed User
Longtime User
Thanks. However, there is corruption when you change orientation. I would add "SV.Bounces=False" to Initialize() in Table to keep the data from separating from the header when you hit the limits.
 

klaus

Expert
Licensed User
Longtime User
1) Screen orientation OK, it was not a problem in the class but how I added the TableViews.
2) The data is no more separated from the header during bouncing.
3) Added the Bounces property.
I updated the file in post#4, I left the version number V1.10.
 

fishwolf

Well-Known Member
Licensed User
Longtime User
I use this module with success, but when i enter the second time into page with table, the design table is corrupt.

In this case i had add a table to ThreePage example (note to top a part of table)

B4X:
Public Sub ShowModule
   If pg.IsInitialized = False Then
     pg.Initialize("pg")
     pg.RootPanel.LoadLayout("ColorsLayout")
     Dim items As List
     items.Initialize
     For Each clr As String In clrs.Keys
       Dim s As AttributedString
       s.Initialize(clr, Font.DEFAULT, clrs.Get(clr))
       items.Add(s)
     Next
     Picker1.SetItems(0, items)
   End If
   Main.NavControl.ShowPage(pg)
   btnChoose.Color = GetSelectedColor
  
   TableResults.Initialize(Me, "TableResults", 7)
   TableResults.AddToParent(pg.RootPanel, 0, 50%y, 100%x, 50%y)
   TableResults.SetHeader(Array As String("Data", "Prove", "Arr", "Tp", "E/R", "Pen", "Qual"))
  
   For i = 0 To 100
     TableResults.AddRow(Array As String("Row: " & i, "ccc", "ddd", "eee", "ccc", "ddd", "eee"))
   Next
  
End Sub

also with the new vesion the design table is corrupt when enter the second times into ColorsModule

attach the project:
 

Attachments

  • TableCorruptPage.zip
    10.7 KB · Views: 20

klaus

Expert
Licensed User
Longtime User
The problem is not the class.
The problem is in your code !
Every time you show ColorsModule you add a new Table !?
You must move the code adding the Table in the IsInitialized part of the code:
B4X:
Public Sub ShowModule
    If pg.IsInitialized = False Then
        pg.Initialize("pg")
        pg.RootPanel.LoadLayout("ColorsLayout")
        Dim items As List
        items.Initialize
        For Each clr As String In clrs.Keys
            Dim s As AttributedString
            s.Initialize(clr, Font.DEFAULT, clrs.Get(clr))
            items.Add(s)
        Next
        Picker1.SetItems(0, items)

        TableResults.Initialize(Me, "TableResults", 7)
        TableResults.AddToParent(pg.RootPanel, 0, 50%y, 100%x, 50%y)
        TableResults.SetHeader(Array As String("Data", "Prove", "Arr", "Tp", "E/R", "Pen", "Qual"))
     
        For i = 0 To 100
            TableResults.AddRow(Array As String("Row: " & i, "ccc", "ddd", "eee", "ccc", "ddd", "eee"))
        Next
    End If
    Main.NavControl.ShowPage(pg)
    btnChoose.Color = GetSelectedColor
End Sub
 
Last edited:

fishwolf

Well-Known Member
Licensed User
Longtime User
Thanks
i was sure that the problem is into my code :)

sorry, i have modify the code and work fine

but if i add a second table into other page the problem return
 

Attachments

  • TableCorruptPage.zip
    10.8 KB · Views: 13

Turbo3

Active Member
Licensed User
Longtime User
I added the following code to ThreePages as suggested above to allow orientation change re-sizing.
B4X:
Private Sub pg_Resize (Width As Int, Height As Int)
    TableResults.Top =50%y
    TableResults.Height=45%y
    TableResults.Width =100%x
End Sub
However, this introduces a side effect that does not allow you to scroll and see the last line. You can see it while you have your finger scrolling but as soon as you remove your finger row 100 goes off screen and the last row you see is 99. If you don't have bounce enabled you can't see row 100 at all.

Is this a code problem in ThreePages or in Tables or is there more that needs to be added to the Resize code I added?
 
Last edited:

Turbo3

Active Member
Licensed User
Longtime User
Here is a modified version of ThreePages that includes the re-size code that then results in not being able to keep Row 100 visible.

I use an iPhone 4 so I need to start the program in landscape mode to have the first column display the row numbers.

I am starting to think it is a bug in ScrollView.

Have a look and see what the problem is.

If you disable bounce then you will never be able to see row 100. But comment out the pg_resize code and row 100 is back.
 

Attachments

  • DisplayRow100Bug.zip
    10.7 KB · Views: 19
Last edited:

Turbo3

Active Member
Licensed User
Longtime User
That only fixes it for the original orientation (landscape in my test). When I switch to portrait I can now only scroll down to row 98. Also the resize did not really work in portrait as the window size stayed the same with the same number of rows visible as in landscape instead of showing more rows on the taller screen.

Please add this new Resize to the test code I uploaded and try changing the orientation.

If you think it works then post the modified code so I can see how you did it.
 

klaus

Expert
Licensed User
Longtime User
Attached you find a working version.
It removes and regenerates the table in the Resize routine.
The Table class has new peoperies: RemoveFromParentView and IsInitialized.

PS: For the last entry not displayed was due to an error, in the Height property change (in the class version in post#4).
 

Attachments

  • DisplayRow100Bug_New.zip
    10.7 KB · Views: 55

fishwolf

Well-Known Member
Licensed User
Longtime User
I've uploaded a new version of TableView (v1.01). I've added a Resize method which you can call in Page_Resize event to correctly resize the table.

with versione 1.01 i have the same problem with 2 tables into 2 pagse, the second table is corrupt only if i show the first.

i suppose that 2 instance have some data shared or i use bad :)

attach the project
 

Attachments

  • TableCorruptPage.zip
    10.2 KB · Views: 12

tufanv

Expert
Licensed User
Longtime User
I am using 1.1 version of Klaus. I can add rows to table 1
but in another panel i initialized table2 I can see the headers but cant add any rows ( it doesnt show the rows whereas table1 shows its rows )
( ı checked the coloumn number of table 2 and addrow event they have the same number but still no luck
Attached your project working.
It's the same solution as in post #15.

)
 

tufanv

Expert
Licensed User
Longtime User
I realized that there is a problem with height of the table
table1.AddToparent(panelnewaircraft, 0, 40dip, 100%x, 150%y) altough this is the code, i can only see 1 line with 100%y i cant see anthing. Where is the mistake on my side =?
 
Status
Not open for further replies.
Top