Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private B4XTable1 As B4XTable
Private ColumnKey, Column1 As B4XTableColumn
Private CSBuilders As Map
End Sub
Public Sub Initialize
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
ColumnKey = B4XTable1.AddColumn("key", B4XTable1.COLUMN_TYPE_NUMBERS)
Column1 = B4XTable1.AddColumn("Col 1", B4XTable1.COLUMN_TYPE_VOID)
B4XTable1.AddColumn("Col 2", B4XTable1.COLUMN_TYPE_NUMBERS)
B4XTable1.VisibleColumns.RemoveAt(0) 'remove the key column
CSBuilders.Initialize
Dim data As List
data.Initialize
For i = 0 To 77
Dim cs As CSBuilder
cs.Initialize
cs.Bold.Color(xui.Color_Red).Append("Item ").PopAll.Color(xui.Color_Blue).Append(i).PopAll
CSBuilders.Put(i, cs)
data.Add(Array(i, i * 17))
Next
B4XTable1.SetData(data)
End Sub
Private Sub B4XTable1_DataUpdated
For i = 0 To B4XTable1.VisibleRowIds.Size - 1
Dim id As Long = B4XTable1.VisibleRowIds.Get(i)
If id = 0 Then Continue
Dim row As Map = B4XTable1.GetRow(id)
Dim key As Int = row.Get(ColumnKey.Id)
Dim cs As CSBuilder = CSBuilders.Get(key)
XUIViewsUtils.SetTextOrCSBuilderToLabel(Column1.CellsLayouts.Get(i + 1).As(B4XView).GetView(Column1.LabelIndex), cs)
Next
End Sub