Android Question B4XTable not everything is clear for me.. (change font and size)

SimonAndroid

Active Member
Licensed User
Longtime User
Hi, I've been using B4A for a short time, so I don't have any things that are fundamental for me.
1. How can I change the size and font type of a single column of a B4XTable, I could not find an example.
2. How can I padding the column of a B4XTable it's possible?
3. In addition to the B4XTable there is another more powerful object as an alternative.
Thank you
 

SimonAndroid

Active Member
Licensed User
Longtime User
1. How can I change the size and font type of a single column of a B4XTable, I could not find an example.
2. How can I padding the column of a B4XTable it's possible?
I didn't understand if steps 1 and 2 are achievable, is there the possibility of intervening on the functionality of the individual columns of a B4XTable?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Better to start with the actual questions and only then assume that you need a more powerful solution.

B4X:
B4XTable1.MaximumRowsPerPage = 20
B4XTable1.BuildLayoutsCache(B4XTable1.MaximumRowsPerPage)
For i = 1 To StateColumn.CellsLayouts.Size - 1
    Dim pnl As B4XView = StateColumn.CellsLayouts.Get(i)
    Dim lbl As Label = pnl.GetView(0)
    lbl.Typeface = Typeface.DEFAULT_BOLD
    lbl.TextSize = 20
    lbl.Padding = Array As Int (10dip, 10dip, 10dip, 10dip)
Next
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I read first the questions in the Italian forum (there is the same question):

1587392193015.png
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Just a starting idea (who will help me? ;))

B4X:
' Note - you should first set BuildLayoutsCache:
'    Example:
'    B4XTable1.MaximumRowsPerPage = 20
'    B4XTable1.BuildLayoutsCache(B4XTable1.MaximumRowsPerPage)
Sub SetColumnCellProps(xTable As B4XTable, ColumnIndex As Int, Properties As Map)
    Dim xColumn As B4XTableColumn = xTable.Columns.Get(ColumnIndex)
    For i = 1 To xColumn.CellsLayouts.Size - 1
        Dim pnl As B4XView = xColumn.CellsLayouts.Get(i)
        Dim lbl As Label = pnl.GetView(0)
        ' Here set the lbl properties.
        Dim PropName As String
        Dim PropValue As Object
        For p = 0 To Properties.Size - 1
            PropName = Properties.GetKeyAt(p)
            PropValue = Properties.GetValueAt(p)
'            lbl.Typeface = Typeface.DEFAULT_BOLD
'            lbl.TextSize = 20
'            lbl.Padding = Array As Int (10dip, 10dip, 10dip, 10dip)
        Next
    Next
End Sub
[Constants for the name of the properties will be "necessary"]


P.S.
B4X:
Public Const XCLMN_PROP_TEXTSIZE As String = "TextSize"


' Note - you should first set BuildLayoutsCache:
'    Example:
'    B4XTable1.MaximumRowsPerPage = 20
'    B4XTable1.BuildLayoutsCache(B4XTable1.MaximumRowsPerPage)
Sub SetColumnCellProps(xTable As B4XTable, ColumnIndex As Int, Properties As Map)
    Dim xColumn As B4XTableColumn = xTable.Columns.Get(ColumnIndex)
    For i = 1 To xColumn.CellsLayouts.Size - 1
        Dim pnl As B4XView = xColumn.CellsLayouts.Get(i)
        Dim lbl As Label = pnl.GetView(0)
        ' Here set the lbl properties.
        Dim PropName As String
        Dim PropValue As Object
        For p = 0 To Properties.Size - 1
            PropName = Properties.GetKeyAt(p)
            PropValue = Properties.GetValueAt(p)
            Select PropName
                Case XCLMN_PROP_TEXTSIZE
                    lbl.TextSize = PropValue
            End Select
        Next
    Next
End Sub

SetColumnCellProps(B4XTable1, 0, CreateMap(XCLMN_PROP_TEXTSIZE:10))
 
Last edited:
Upvote 0
Top