Android Question B4XTable: how to change the color of cells according to its content

voxel

Member
Licensed User
Hello,
I would like to change the cell color of a column based on this content. For example, if the cell contains the character string "test", display the background of the cell in red. I would like to try and start from this sample exemple code "CreaterCustomFormat" (that sounds like a good start to me). Thanks for your help.


B4X:
Private Sub CreateCustomFormat (c As B4XTableColumn)

    Dim formatter As B4XFormatter
    formatter.Initialize
    c.Formatter = formatter
  
    Dim Negative As B4XFormatData = c.Formatter.CopyFormatData(Positive)
    Negative.TextColor = xui.Color_Red
    Negative.FormatFont = xui.CreateDefaultBoldFont(16)
    Negative.Prefix = "("
    Negative.Postfix = ")"
    c.Formatter.AddFormatData(Negative,c.Formatter.MIN_VALUE, 0, False)

End Sub
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0
Top