B4J Question B4XTable - Text align does not work [SOLVED]

jcesar

Active Member
Licensed User
Longtime User
Hi

I'm trying align a b4xtable cell text, but it's not working. Here is my code:


B4X:
B4XTable1.MaximumRowsPerPage = 20
B4XTable1.BuildLayoutsCache(B4XTable1.MaximumRowsPerPage)
If xui.IsB4J Then B4XTable1.HighlightSearchResults = False
Dim idColumn As B4XTableColumn = B4XTable1.AddColumn("id", B4XTable1.COLUMN_TYPE_TEXT)
idColumn.Width = 60dip
SetColumnHorizontalAlignment(idColumn, "LEFT")
Dim nameColumn As B4XTableColumn = B4XTable1.AddColumn("Name", B4XTable1.COLUMN_TYPE_TEXT)
SetColumnHorizontalAlignment(nameColumn, "LEFT")
Dim imageColumn As B4XTableColumn = B4XTable1.AddColumn("Image", B4XTable1.COLUMN_TYPE_TEXT)
SetColumnHorizontalAlignment(imageColumn, "LEFT")

...

Private Sub SetColumnHorizontalAlignment(Col As B4XTableColumn, Alignment As String)
    For i = 1 To Col.CellsLayouts.Size - 1
        Dim p As B4XView = Col.CellsLayouts.Get(i)
        p.GetView(Col.LabelIndex).SetTextAlignment("CENTER", Alignment)
    Next
End Sub
 

Attachments

  • b4xtable.png
    b4xtable.png
    54.2 KB · Views: 133

mangojack

Expert
Licensed User
Longtime User
Try this flow ... It should then work.
B4X:
Dim idColumn As B4XTableColumn = B4XTable1.AddColumn("id", B4XTable1.COLUMN_TYPE_TEXT)
idColumn.Width = 60dip
Dim nameColumn As B4XTableColumn = B4XTable1.AddColumn("Name", B4XTable1.COLUMN_TYPE_TEXT)
Dim imageColumn As B4XTableColumn = B4XTable1.AddColumn("Image", B4XTable1.COLUMN_TYPE_TEXT)

B4XTable1.MaximumRowsPerPage = 20
B4XTable1.BuildLayoutsCache(B4XTable1.MaximumRowsPerPage)
If xui.IsB4J Then B4XTable1.HighlightSearchResults = False

SetColumnHorizontalAlignment(idColumn, "LEFT")
SetColumnHorizontalAlignment(nameColumn, "LEFT")
SetColumnHorizontalAlignment(imageColumn, "LEFT")
...

Private Sub SetColumnHorizontalAlignment(Col As B4XTableColumn, Alignment As String)
    For i = 1 To Col.CellsLayouts.Size - 1
        Dim p As B4XView = Col.CellsLayouts.Get(i)
        p.GetView(Col.LabelIndex).SetTextAlignment("CENTER", Alignment)
    Next
End Sub
 
Upvote 0
Top