B4J Code Snippet Tableview header wrap text

SubName: SetTableHeaderWrap

Allows the table view header text to wrap.


B4X:
Sub SetTableHeaderWrap(Table As JavaObject, PrefHeight As Int)

    Dim HeaderRow As Pane = Table.RunMethod("lookup",Array("TableHeaderRow"))
    For Each N As JavaObject In HeaderRow.GetAllViewsRecursive
        If N Is Label Then
            Dim NL As Label = N
            If PrefHeight <> -1 Then NL.PrefHeight = PrefHeight
            'Seems to lose the text centering
            CSSUtils.SetStyleProperty(NL,"-fx-text-alignment","center")
            N.RunMethod("setWrapText",Array(True))
        End If
    Next
End Sub

Set the PrefHeight to -1 to leave it unchanged.

Dependencies: JavaObject, CSSUtils

CSSUtils is available here: https://www.b4x.com/android/forum/threads/class-cssutils.61824/

Tags: B4j TableView Header Wrap Text Get Header Row
 
Last edited:

stevel05

Expert
Licensed User
Longtime User
Yes, I forgot about that one. I Should get used to using it. Will change it. Thanks
 
Last edited:
Top