Android Question How to change text color in CLVSwipe, or use icons?

HappyDad

Member
Licensed User
Longtime User
In CustomListView Swipe:
The default text color is black.
Can I change text color to other colors?
And, can I use icons, instead of text?
 

Mahares

Expert
Licensed User
Longtime User
The default text color is black.
Can I change text color to other colors?
B4X:
CustomListView1.DefaultTextColor = xui.Color_Red
And, can I use icons, instead of text?
B4X:
Sub CreateItems
    Dim cs As CSBuilder
    For i = 1 To 50
        cs.Initialize
        If i Mod 3 = 0 Then
            cs.Append($"This is airplane: ${i}"$).Typeface(Typeface.MATERIALICONS).Append(Chr(0xE195)).PopAll
            CustomListView1.AddTextItem(cs, Swipe.CreateItemValue("", Array("Delete", "Fly to Airport")))
        Else If i Mod 3 = 1 Then
            cs.Append($"Very important item ${i} ..."$).PopAll
            CustomListView1.AddTextItem(cs, Swipe.CreateItemValue("", Array("Action 1", "Action 2", "Action 3")))
        Else
            cs.Append($"Nothing to see here ${i}"$).PopAll
            CustomListView1.AddTextItem(cs, Null)
        End If
    Next
End Sub
 
Upvote 0

HappyDad

Member
Licensed User
Longtime User
B4X:
CustomListView1.DefaultTextColor = xui.Color_Red

B4X:
Sub CreateItems
    Dim cs As CSBuilder
    For i = 1 To 50
        cs.Initialize
        If i Mod 3 = 0 Then
            cs.Append($"This is airplane: ${i}"$).Typeface(Typeface.MATERIALICONS).Append(Chr(0xE195)).PopAll
            CustomListView1.AddTextItem(cs, Swipe.CreateItemValue("", Array("Delete", "Fly to Airport")))
        Else If i Mod 3 = 1 Then
            cs.Append($"Very important item ${i} ..."$).PopAll
            CustomListView1.AddTextItem(cs, Swipe.CreateItemValue("", Array("Action 1", "Action 2", "Action 3")))
        Else
            cs.Append($"Nothing to see here ${i}"$).PopAll
            CustomListView1.AddTextItem(cs, Null)
        End If
    Next
End Sub

Thanks!
I tried the 'DefaultTextColor', but the text color is still black.
I mean the text of the action buttons coming out when swiping.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I mean the text of the action buttons coming out when swiping.
This should do it for you. In the CLVSwipe class module, change this line:
B4X:
xlbl.TextColor = xui.Color_Black
to this:
B4X:
xlbl.TextColor = xui.Color_Magenta   'or whatever color you wish
The CreateActionButtons sub in the class module may even allow you to create and initialize a CSBuilder for the label xlbl to display icons.
 
Upvote 0
Top