Sub Class_Globals
Private Root As B4XView 'ignore
Private xui As XUI 'ignore
Public SQL1 As SQL
Private B4XTable1 As B4XTable
Private B4XTable2 As B4XTable
Public TypeColumn As B4XTableColumn
End Sub
'You can add more parameters here.
Public Sub Initialize As Object
Return Me
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
'load the layout to Root
Root.LoadLayout("Table1")
Private parser As CSVParser
parser.Initialize
'create the columns
B4XTable1.SearchVisible = False
Private ID1Column As B4XTableColumn = B4XTable1.AddColumn("ID", B4XTable1.COLUMN_TYPE_TEXT)
ID1Column.Width = 50dip
Private DNColumn As B4XTableColumn = B4XTable1.AddColumn("DN/mm", B4XTable1.COLUMN_TYPE_TEXT)
DNColumn.Width = 100dip
Private DiColumn As B4XTableColumn = B4XTable1.AddColumn("Di/mm", B4XTable1.COLUMN_TYPE_TEXT)
DiColumn.Width = 100dip
Private data1 As List = parser.Parse(File.ReadString(File.DirAssets, "Table1.csv"), ",", True)
B4XTable1.SetData(data1)
' B4XTable2.RowHeight = 80dip
B4XTable2.SearchVisible = False
Private ID2Column As B4XTableColumn = B4XTable2.AddColumn("ID", B4XTable2.COLUMN_TYPE_TEXT)
ID2Column.Width = 50dip
' Private TypeColumn As B4XTableColumn = B4XTable2.AddColumn("管子类型", B4XTable2.COLUMN_TYPE_TEXT)
TypeColumn = B4XTable2.AddColumn("管子类型", B4XTable2.COLUMN_TYPE_TEXT)
SetWrapText(TypeColumn)
Private RoughColumn As B4XTableColumn = B4XTable2.AddColumn("等值粗糙度(mm)", B4XTable2.COLUMN_TYPE_TEXT)
RoughColumn.Width = 140dip
Private data2 As List = parser.Parse(File.ReadString(File.DirAssets, "Table2.csv"), ",", True)
B4XTable2.SetData(data2)
' B4XTable2.Refresh
End Sub
Private Sub SetWrapText(Col As B4XTableColumn)
For i = 1 To Col.CellsLayouts.Size - 1
Dim p As B4XView = Col.CellsLayouts.Get(i)
' Dim lbl As Label = p.GetView(0)
Dim lbl As Label = p.GetView(Col.LabelIndex)
Dim lb4x As B4XView =lbl
#if B4A
lbl.SingleLine =False
lb4x.textColor=xui.Color_Red
#end if
#if B4J
lbl.WrapText = True
lb4x.textColor =xui.Color_Magenta
#End If
Next
End Sub