iOS Question xcustomlistview swipe

Claude Brun

Active Member
Licensed User
Longtime User
hi,
In the tutorial the swipe is added to the CLV by the following code
addtextitem:
CustomListView1.AddTextItem($"Important item ${i} ..."$, Swipe.CreateItemValue("", Array("Delete", "Do Something Else")))

In my case, I have multiple columns in my item, so I can't use the addtextitem. I'm using the following code
createlistitem:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    dd.Initialize
    'The designer script calls the DDD class. A new class instance will be created if needed.
    'In this case we want to create it ourselves as we want to access it in our code.
    xui.RegisterDesignerClass(dd)
    Swipe.Initialize(clv2, Me, "Swipe")
    Swipe.ActionColors = CreateMap("Delete": xui.Color_Red)
    Root.LoadLayout("MainPage")
'    Swipe.ActionColors = CreateMap("Delete": xui.Color_Red, "Do Something Else": xui.Color_Green)
    For i = 1 To 20
        clv2.Add(CreateListItem($"Item #${i}"$, $"colonne 2"$, clv2.AsView.Width, 22dip), $"id${i}"$)
    Next
    clv2_sel = -1
    color_clv2(clv2_sel)   
    #if B4A
    B4XPages.AddMenuItem(Me, "Toggle Scrolling")
    #end if
End Sub

Private Sub CreateListItem(Text1 As String, Text2 As String, Width As Int, Height As Int) As B4XView
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0, Width, Height)
    p.LoadLayout("CellItem")
    'Note that we call DDD.CollectViewsData in CellItem designer script. This is required if we want to get views with dd.GetViewByName.
    dd.GetViewByName(p, "Label1").Text = Text1
    dd.GetViewByName(p, "Label2").Text = Text2
    Return p
End Sub

How to add the swipe to each item in my case

Thank
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…