Hello, i have problems updating a TableView
NOTE that i did not used B4J much till now. But for the tool i want to write i need to do it with B4J as it need to run on Windows; not B4A
Please be patience ;-)
The Initial list is done with this code
where WrapLabel is this code i found in the Forum:
Problem:
After filling the Table with the 20 rows (max) i need to Update all the Rows and Columns twice a second.
If i use this code directly after creating the Table
I get the expected results. The reference to the anchorpane
but when i run the app and i get new data which i want to put into the 20 Table rows i do not get the AnchorPanes
I´m wondering what i am doing wrong that causes not to return the AnchorPanes for the rows i want to update.
Is there some tutorial about it? Does someone have an idea what could be wrong?
As i am in a very early stage of the app i can switch to another Object if it make sense to use another TableObject (if available).
Or should i simple switch to xCLV (xCustomListView)? Time writing it i think i should give it a short try. I expect it to be easy to switch as i am more familar with xCLV instead of TableView ;-)
Any hints/tips are highly welcome
NOTE that i did not used B4J much till now. But for the tool i want to write i need to do it with B4J as it need to run on Windows; not B4A
Please be patience ;-)

The Initial list is done with this code
B4X:
For o = 0 To driverlist.Size-1
Dim driver As RaceDriver = driverlist.Get(o)
'0 Pos
'1 Fahrer
'2 Team
'3 Grid
'4 Stopps
'5 BestLap
'6 Sektor1
'7 Sektor2
'8 PKT
Dim lblPos, lblPlusMinus, lblFahrer, lblTeam, lblGrid, lblStops, lblBestLap, lblSektor1, lblSektor2, lblPKT As Label
lblPos.Initialize("")
lblPos.Text = driver.pos
lblPos.Font = fx.DefaultFont(12)
lblPos.TextColor = fx.Colors.Black
Dim verbesserung As Int = 0
Dim gridpos As Int = driver.pos
If o=gridpos Then
verbesserung = 0
else if o > gridpos Then
verbesserung = gridpos-o
else if o < gridpos Then
verbesserung = gridpos-o
End If
lblPlusMinus.Initialize("")
lblPlusMinus.Font = fx.CreateFontAwesome(12)
If driver.pos < driver.Grid Then
lblPlusMinus.TextColor = fx.Colors.Green
'lblPlusMinus.Style = $"-fx-background-image: url(${File.GetUri(File.DirAssets, "up.png")});"$
Else If driver.pos > driver.Grid Then
lblPlusMinus.TextColor = fx.Colors.Red
'lblPlusMinus.Style = $" -fx-background-image: url(${File.GetUri(File.DirAssets, "down.png")});"$
End If
If verbesserung > 0 Then
lblPlusMinus.Text = "+"&verbesserung
Else
lblPlusMinus.Text = verbesserung
End If
Dim color As String
If o Mod 2 = 0 Then color = "palegreen" Else color = "skyblue"
lblPos.Style = "-fx-background-color: " & color & ";"
lblFahrer.Initialize("")
lblFahrer.Text = driver.Driver
lblFahrer.Font = fx.DefaultFont(12)
lblFahrer.TextColor = fx.Colors.Blue
lblTeam.Initialize("")
lblTeam.Text = driver.Team
lblTeam.Font = fx.DefaultFont(12)
lblTeam.TextColor = fx.Colors.Green
lblGrid.Initialize("")
lblGrid.Text = driver.Grid
lblGrid.Font = fx.DefaultFont(12)
lblGrid.TextColor = fx.Colors.Black
lblStops.Initialize("")
lblStops.Text = driver.stopps
lblStops.Font = fx.DefaultFont(12)
lblStops.TextColor = fx.Colors.Black
lblBestLap.Initialize("")
lblBestLap.Text = driver.BestLap
lblBestLap.Font = fx.DefaultFont(12)
lblBestLap.TextColor = fx.Colors.Magenta
lblSektor1.Initialize("")
lblSektor1.Text = driver.Sector1Time
lblSektor1.Font = fx.DefaultFont(12)
lblSektor1.TextColor = fx.Colors.Yellow
lblSektor2.Initialize("")
lblSektor2.Text = driver.Sector2Time
lblSektor2.Font = fx.DefaultFont(12)
lblSektor2.TextColor = fx.Colors.Black
lblPKT.Initialize("")
lblPKT.Text = driver.Punkte
lblPKT.Font = fx.DefaultFont(12)
lblPKT.TextColor = fx.Colors.Black
rd.GetTable.Items.Set(o,Array As Object(WrapLabel(lblPos, "CENTER"), WrapLabel(lblPlusMinus, "CENTER"), WrapLabel(lblFahrer, "CENTER_LEFT"), WrapLabel(lblTeam, "CENTER_LEFT"), WrapLabel(lblGrid, "CENTER_LEFT"), WrapLabel(lblStops, "CENTER_LEFT"), WrapLabel(lblBestLap, "CENTER_LEFT"), WrapLabel(lblSektor1, "CENTER_LEFT"), WrapLabel(lblSektor2, "CENTER_LEFT"), WrapLabel(lblPKT, "CENTER_LEFT")))
'rd.GetTable.Items.Set(o,Array As Object(WrapLabel(lblPos, "CENTER"), WrapLabel(lblFahrer, "CENTER LEFT"), WrapLabel(lblTeam, "CENTER LEFT"), WrapLabel(lblGrid, "CENTER LEFT"), WrapLabel(lblStops, "CENTER LEFT"), WrapLabel(lblBestLap, "CENTER LEFT"), WrapLabel(lblSektor1, "CENTER LEFT"), WrapLabel(lblSektor2, "CENTER LEFT"), WrapLabel(lblPKT, "CENTER LEFT")))
'rd.GetTable.Items.Set(i,driver)
Next
where WrapLabel is this code i found in the Forum:
B4X:
Sub WrapLabel(lbl As Label, Alignment As String) As Pane
Dim pn1 As AnchorPane
pn1.Initialize("")
pn1.AddNode(lbl, 0, 0, -1, -1)
pn1.FillHorizontally(lbl, 0, 0)
Dim jo1 = lbl As JavaObject
jo1.RunMethod("setAlignment", Array As Object(Alignment))
Return pn1
End Sub
Problem:
After filling the Table with the 20 rows (max) i need to Update all the Rows and Columns twice a second.
If i use this code directly after creating the Table
B4X:
Dim objarr() As Object = rd.GetTable.Items.Get(0)
Log("RaceData #"&o&" Content: "&objarr)
Log("ContentLength: "&objarr.Length)
Log(GetType(objarr(0)))
Log(GetType(objarr(1)))
Log(GetType(objarr(2)))
Log(GetType(objarr(3)))
I get the expected results. The reference to the anchorpane
RaceData Table Size 20
RaceData #0 Content: [Ljava.lang.Object;@1fc1da7
ContentLength: 10
javafx.scene.layout.AnchorPane
javafx.scene.layout.AnchorPane
javafx.scene.layout.AnchorPane
javafx.scene.layout.AnchorPane
but when i run the app and i get new data which i want to put into the 20 Table rows i do not get the AnchorPanes
RaceData #0 Content: [Ljava.lang.Object;@d9d7aa
ContentLength: 9
java.lang.Integer
java.lang.String
java.lang.String
java.lang.Integer
RaceData Table Size 20
RaceData #1 Content: [Ljava.lang.Object;@1bcf171
ContentLength: 9
java.lang.Integer
java.lang.String
java.lang.String
java.lang.Integer
RaceData Table Size 20
RaceData #2 Content: [Ljava.lang.Object;@1b4cb4e
ContentLength: 9
java.lang.Integer
java.lang.String
java.lang.String
java.lang.Integer
RaceData Table Size 20
RaceData #3 Content: [Ljava.lang.Object;@15f4047
ContentLength: 9
java.lang.Integer
java.lang.String
java.lang.String
java.lang.Integer
RaceData Table Size 20
RaceData #4 Content: [Ljava.lang.Object;@1c9a281
ContentLength: 9
java.lang.Integer
java.lang.String
java.lang.String
java.lang.Integer
RaceData Table Size 20
RaceData #5 Content: [Ljava.lang.Object;@160f330
ContentLength: 9
java.lang.Integer
java.lang.String
java.lang.String
java.lang.Integer
RaceData Table Size 20
RaceData #6 Content: [Ljava.lang.Object;@afaaa9
ContentLength: 9
java.lang.Integer
java.lang.String
java.lang.String
java.lang.Integer
RaceData Table Size 20
RaceData #7 Content: [Ljava.lang.Object;@10787c3
ContentLength: 9
java.lang.Integer
java.lang.String
java.lang.String
java.lang.Integer
RaceData Table Size 20
RaceData #8 Content: [Ljava.lang.Object;@16ae608
ContentLength: 9
java.lang.Integer
java.lang.String
java.lang.String
java.lang.Integer
RaceData Table Size 20
RaceData #9 Content: [Ljava.lang.Object;@1f76ca6
ContentLength: 9
java.lang.Integer
java.lang.String
java.lang.String
java.lang.Integer
RaceData Table Size 20
RaceData #10 Content: [Ljava.lang.Object;@327893
ContentLength: 9
java.lang.Integer
java.lang.String
java.lang.String
java.lang.Integer
RaceData Table Size 20
RaceData #11 Content: [Ljava.lang.Object;@180d549
ContentLength: 9
java.lang.Integer
java.lang.String
java.lang.String
java.lang.Integer
RaceData Table Size 20
RaceData #12 Content: [Ljava.lang.Object;@18a3317
ContentLength: 9
java.lang.Integer
java.lang.String
java.lang.String
java.lang.Integer
RaceData Table Size 20
RaceData #13 Content: [Ljava.lang.Object;@1c0ed1c
ContentLength: 9
java.lang.Integer
java.lang.String
java.lang.String
java.lang.Integer
RaceData Table Size 20
RaceData #14 Content: [Ljava.lang.Object;@f9f097
ContentLength: 9
java.lang.Integer
java.lang.String
java.lang.String
java.lang.Integer
RaceData Table Size 20
RaceData #15 Content: [Ljava.lang.Object;@102555c
ContentLength: 9
java.lang.Integer
java.lang.String
java.lang.String
java.lang.Integer
RaceData Table Size 20
RaceData #16 Content: [Ljava.lang.Object;@1c6c4e0
ContentLength: 9
java.lang.Integer
java.lang.String
java.lang.String
java.lang.Integer
RaceData Table Size 20
RaceData #17 Content: [Ljava.lang.Object;@1367309
ContentLength: 9
java.lang.Integer
java.lang.String
java.lang.String
java.lang.Integer
RaceData Table Size 20
RaceData #18 Content: [Ljava.lang.Object;@145f30
ContentLength: 9
java.lang.Integer
java.lang.String
java.lang.String
java.lang.Integer
RaceData Table Size 20
RaceData #19 Content: [Ljava.lang.Object;@1ef50db
ContentLength: 9
java.lang.Integer
java.lang.String
java.lang.String
java.lang.Integer
I´m wondering what i am doing wrong that causes not to return the AnchorPanes for the rows i want to update.
Is there some tutorial about it? Does someone have an idea what could be wrong?
As i am in a very early stage of the app i can switch to another Object if it make sense to use another TableObject (if available).
Or should i simple switch to xCLV (xCustomListView)? Time writing it i think i should give it a short try. I expect it to be easy to switch as i am more familar with xCLV instead of TableView ;-)
Any hints/tips are highly welcome
Last edited: