You can add labels as the items instead of strings. This will allow you to change the labels background color (with CSSUtils.SetBackgroundColor).
'setting table colums
tblCS.SetColumns(Array As String("Key Name", "Company", "ID", "Key Type"))
tblCS.SetColumnWidth(0, 145)
tblCS.SetColumnWidth(1, 145)
tblCS.SetColumnWidth(2, 75)
tblCS.SetColumnWidth(3, 35)
Dim aRow(4) As Object
Dim str As String = k.GetString(Main.strMKDirLoc,f)
aRow(0) = k.GetKey("kn", str)
aRow(1) = k.GetKey("cn", str)
aRow(2) = f
aRow(3) = k.GetKey("kt", str)
tblCS.Items.Add(aRow)
C = C + 1
There is an example here: https://www.b4x.com/android/forum/threads/tableview-cell-alignment-and-color.35364/#post-208851
Remember to use CSSUtils instead of modifying the style property.
Dim lb1, lb2, lb3, lb4 As Label
lb1.Initialize("")
lb2.Initialize("")
lb3.Initialize("")
lb4.Initialize("")
lb1.Text = KeyName
lb2.Text = k.GetKey("cn", str)
lb3.Text = f
lb4.Text = kt
If KeyType = "SGK" Then
lb1.TextColor = fx.Colors.LightGray
lb2.TextColor = fx.Colors.LightGray
lb3.TextColor = fx.Colors.LightGray
lb4.TextColor = fx.Colors.LightGray
Else
lb1.TextColor = fx.Colors.Blue
lb2.TextColor = fx.Colors.Blue
lb3.TextColor = fx.Colors.Blue
lb4.TextColor = fx.Colors.Blue
End If
tblCS.Items.Add(Array As Object(lb1, lb2, lb3, lb4))
If Index <> -1 Then
If Row(3) <> "SGK" Then
btCSOK.Enabled = True
imDelete.Enabled = True
Else
btCSOK.Enabled = False
imDelete.Enabled = False
End If
End If
Each item in Row is a label.
B4X:Dim lbl As Label = Row(3) If lbl.Text = "SGK" Then
Dim lb3 As Label = Row(3)
If Index <> -1 Then
If lb3.Text <> "SGK" Then
btCSOK.Enabled = True
imDelete.Enabled = True
Else
btCSOK.Enabled = False
imDelete.Enabled = False
End If
End If
Dim arow(3) As Object = tblCS.SelectedRowValues
Dim lb1, lb2, lb3 As Label
lb1 = arow(0)
lb2 = arow(1)
lb3 = arow(2)
Dim R(3) As Object
R(0) = lb1.Text
R(1) = lb2.Text
R(2) = lb3.Text
CallSub2(oClassCalled,"AsignCompanySelect",R)
cs.close