Android Question B4XTable lock the property text autosize

SimonAndroid

Active Member
Licensed User
Longtime User
I would like to know how to lock the text autosize in a B4XTable. Basically, by stretching the table row I would always have the single line instead of the text wrapped on multiple lines. The property is present in the Designer but I can't get it from the code, even if set by the Designer it doesn't work correctly.
 

SimonAndroid

Active Member
Licensed User
Longtime User
To better explain my request, I attach an image. I would like to view the list in single line mode.
 

Attachments

  • Annotazione 2020-03-27 152903.png
    Annotazione 2020-03-27 152903.png
    194.8 KB · Views: 150
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
It should be so:
B4X:
Sub SetSingleLine(xColumn As B4XTableColumn)
    For i = 1 To B4XTable1.VisibleRowIds.Size
        Dim pnl As B4XView = xColumn.CellsLayouts.Get(i)
        Dim lbl As Label = pnl.GetView(0)
        lbl.SingleLine = True
        lbl.Ellipsize = "END"
    Next
End Sub
but... it does not work; only if I change to
For i = 0 To B4XTable1.VisibleRowIds.Size
only the header will be truncated.
 
Last edited:
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
So it works:

B4X:
Sub SetSingleLine(xColumn As B4XTableColumn)
    B4XTable1.RefreshNow
    Sleep(100)
    For i = 1 To B4XTable1.VisibleRowIds.Size - 1
        Dim pnl As B4XView = xColumn.CellsLayouts.Get(i)
        Dim lbl As Label = pnl.GetView(0)
        lbl.SingleLine = True
        lbl.Ellipsize = "END"
    Next
End Sub
 
Upvote 0

SimonAndroid

Active Member
Licensed User
Longtime User
A big greeting for your availability and experience @LucaMs. In the end I introduced your sub in my procedure as follows and works well.

SetSingleLine:
Sub SetSingleLine(xRow As Int, xColumn As B4XTableColumn, SingleLine As Boolean, Ellipsize As String)
        Dim pnl As B4XView = xColumn.CellsLayouts.Get(xRow)
        Dim lbl As Label = pnl.GetView(0)
        lbl.SingleLine = SingleLine
        lbl.Ellipsize = Ellipsize
End Sub

Sub B4XTable1_DataUpdated
    For i = 1 To B4XTable1.VisibleRowIds.Size - 1
        For j = 0 To B4XTable1.Columns.size - 1
            Dim column As B4XTableColumn = B4XTable1.Columns.Get(j)
            SetSingleLine(i, column,True,"END")
        Next
    Next  
End Sub
 
Upvote 0

SimonAndroid

Active Member
Licensed User
Longtime User
Last modification for not having problems with the last line of the table..

SetSingleLine:
Sub SetSingleLine(xRow As Int, xColumn As B4XTableColumn, SingleLine As Boolean, Ellipsize As String)
        Dim pnl As B4XView = xColumn.CellsLayouts.Get(xRow)
        Dim lbl As Label = pnl.GetView(0)
        lbl.SingleLine = SingleLine
        lbl.Ellipsize = Ellipsize
End Sub

Sub B4XTable1_DataUpdated
    For i = 1 To B4XTable1.VisibleRowIds.Size  '  I replaced -1 otherwise skipped last line 
        For j = 0 To B4XTable1.Columns.size - 1
            Dim column As B4XTableColumn = B4XTable1.Columns.Get(j)
            SetSingleLine(i, column,True,"END")      ' Ellipsize  -> START, END, MIDDLE, NONE
        Next
    Next
End Sub
 
Upvote 0
Top