Android Question Label color not changing in skill list

Tim Chapman

Active Member
Licensed User
Longtime User
When I run the following, I would expect the text color to be red on the first 9 items and green on all the following items in the listview. But they are all green. Thanks in advance for replies!

B4X:
    'Listview Stuff
    SkillList.Initialize("SkillList")
    SkillList.SingleLineLayout.ItemHeight = 30dip
    Label1 = SkillList.SingleLineLayout.Label
    Label1.TextSize = 15
    Label1.Padding = Array As Int (0dip, 0dip, 0dip, 0dip)
   
    For i = 1 To 45
        If i < 10 Then
            Label1.TextColor = Colors.Red
        Else
            Label1.TextColor = Colors.Green
        End If
        SkillList.AddSingleLine(Skills(i))
    Next
 

DonManfred

Expert
Licensed User
Longtime User
You can use CharsequenceBuilder to fill the items individually
But using strings you are limited to ONE Layout per Itemtype (one line, two lines, two lines and bitmap). All items of the same type share the same layout (and color)

B4X:
For i = 1 To 100
   ListView1.AddSingleLine(cs.Initialize.Color(Rnd(0xFF000000, -1)).Alignment("ALIGN_CENTER").Append($"Item #${i}"$).PopAll)
Next
 
Last edited:
Upvote 0

Tim Chapman

Active Member
Licensed User
Longtime User
You can use CharsequenceBuilder to fill the items individually
But using strings you are limited to ONE Layout per Itemtype (one line, two lines, two lines and bitmap). All items of the same taype share the same layout (and color)

B4X:
For i = 1 To 100
   ListView1.AddSingleLine(cs.Initialize.Color(Rnd(0xFF000000, -1)).Alignment("ALIGN_CENTER").Append($"Item #${i}"$).PopAll)
Next
Thank you very much! That did the trick!
 
Upvote 0
Top