Hi,
How to change the background colour of an individual item before .AddTextItem ?
Paul
Maybe you could try changing in the CustomListView Class the following:
B4X:
'Adds a text item. The item height will be adjusted based on the text.
Public Sub AddTextItem(Text As String, Value As Object, BackgroundColor As Int)
InsertAtTextItem(items.Size, Text, Value, BackgroundColor)
End Sub
'Inserts a text item at the specified index.
Public Sub InsertAtTextItem(Index As Int, Text As String, Value As Object, BackgroundColor As Int)
Dim pnl As Panel
pnl.Initialize("")
Dim lbl As Label
lbl.Initialize("")
lbl.Gravity = Bit.Or(Gravity.CENTER_VERTICAL, Gravity.LEFT)
pnl.AddView(lbl, 5dip, 2dip, sv.Width - 5dip, 20dip)
lbl.Text = Text
lbl.TextSize = DefaultTextSize
lbl.TextColor = DefaultTextColor
' If DefaultTextBackground <> Null Then
'pnl.Background = DefaultTextBackground
'Else
pnl.Color = BackgroundColor
'End If
Dim minHeight As Int
minHeight = su.MeasureMultilineTextHeight(lbl, Text)
lbl.Height = Max(50dip, minHeight)
InsertAt(Index, pnl, lbl.Height + 2dip, Value)
End Sub
Example:
B4X:
For i = 1 To 10
If i = 10 Then
clv2.AddTextItem("Text"&i,"",Colors.Blue)
Else
clv2.AddTextItem("Text"&i,"",Colors.Red)
End If
Next