B4J Question [SOLVED ]Change text Color depending on Once cell contents

Peter Lewis

Active Member
Licensed User
Longtime User
Hi

I have used Erel's code to color the complete line but the color of the background does not work well with black. The code works to make the line Red , which is perfect but I want to change the text color. Here is the code.

Thank you for any advise
b4xtable text color:
Sub SetRowColor (RowIndex As Int, Clr As Int)
    For Each c As B4XTableColumn In tblInvDetail.VisibleColumns
        Dim pnl As B4XView = c.CellsLayouts.Get(RowIndex + 1) '+1 because of the header
        pnl.Color = Clr
        
        If Clr = -1761673216 Then 'Red , White is -1
            pnl.TextColor=xui.Color_White
        Else
            pnl.TextColor=xui.Color_black
        End If
    Next
End Sub

I checked on the table which row what which color so that the correct background color went back on the correct row by doing this

Checking if the line should be colored:
        invline(4)=barcount&"/"&totalcount
            If barcount <> totalcount Then
                    SetRowColor(infos.Size,xui.Color_ARGB(150,255,0,0))
            Else
                If infos.Size Mod 2 = 0 Then
                        SetRowColor(infos.Size,xui.Color_RGB(255,255,255))
                Else
                    SetRowColor(infos.Size,xui.Color_RGB(234,234,234))
                End If
            End If
 
Top