Android Question CLVSwipe icon

yiankos1

Well-Known Member
Licensed User
Longtime User
I am using CLVSwipe in order to show actions at a listview. I edit code from CLVSwipe in order to show material icon:
B4X:
Private Sub CreateActionButtons (actions As List) As Int
    ActionsPanel.RemoveAllViews
    Dim LastX As Int = 0
    For Each action As String In actions
        Dim l As Label
        l.Initialize("lbl")
        Dim xlbl As B4XView = l
        xlbl.Text = action
        xlbl.Color = ActionColors.GetDefault(action, xui.Color_White)
        xlbl.SetTextAlignment("CENTER", "CENTER")
        xlbl.Font = xui.CreateMaterialIcons(20)
        xlbl.TextColor = xui.Color_Black
        Dim width As Int = Max(40dip, cvs.MeasureText(action, xlbl.Font).Width + 20dip)
        ActionsPanel.AddView(xlbl, ActionsPanel.Width - width - LastX, 0, width, ActionsPanel.Height)
        LastX = LastX + width
    Next
    Return LastX
End Sub

I face two problems:
1) I can't set the button color because even i set:
B4X:
swipe.ActionColors = CreateMap(Chr(0xE3C9): xui.Color_Red)
it just get the default white color

2) I can't get the ActionText in order to do my delete/edit action on a clv Item
B4X:
Sub Swipe_ActionClicked (Index As Int, ActionText As String)
    Log($"Action clicked: ${Index}, ${ActionText}"$)
End Sub

i recieve this: Action clicked: 1, 

Material icons are shown correctly.

Thank you for your time.
 
Solution
1675922417387.png


1. The keys in the Map should be strings, not chars:
B4X:
Swipe.ActionColors = CreateMap(Chr(0xE3C9).As(String): xui.Color_Red, Chr(0xE3C8).As(String): xui.Color_Yellow)

2. The logs cannot show material icons characters.
B4X:
Select Asc(ActionText)
    Case 0xE3C9:
        Log("abc")
End Select
Top