Android Question How to get value in CLVSwipe (Customlistview)

Tasyo28

Member
Licensed User
Hi,

Good day everyone.

Still understanding how CLVSwipe works, now I'm stuck how to get the stored value return by CLVSwipe.
Please see sample code

B4X:
Sub Swipe_ActionClicked (Index As Int, ActionText As String)
    Log($"Action clicked: ${Index}, ${ActionText}"$)
 
   'i want to get here the value of the map stored in Swipe.CreateItemValue value to assign them to variable

End Sub


Sub Daterecords
   Dim m as map
   Dim OrderHistVal as list
   Dim parser As JSONParser

   parser.Initialize(j.GetString)
   OrderHistVal = parser.NextArray
 
   For i = 1 To OrderHistVal.size - 1
            m = OrderHistVal.Get((i)
            order_id_val = m.Get("order_id")
       
            cs.Initialize.Color(Colors.Blue).Append(order_id_val).PopAll
       
            clv.AddTextItem(cs, Swipe.CreateItemValue(m, Array("Cancel")))
       
   
   Next
End Sub
I tried to get the value using clv.GetValue(index) but i dont know what command to use to get the value on it.

this is the sample output of clv.GetValue(index) inside Swipe_ActionClicked:

[Actions=(ArrayList) [Cancel], IsInitialized=true, IsSwiped=false,MaxSwipe=205, Open=false, Value=[IsInitialized=false, orderid=34]]


As the result of clv.GetValue(index) i can see the value of orderid=34 which is correct, but how to assign it and get it as variable using the Swipe_ActionClicked.

Thanks for helping.
 
Last edited:

DonManfred

Expert
Licensed User
B4X:
Sub Swipe_ActionClicked (Index As Int, ActionText As String)
    Log($"Action clicked: ${Index}, ${ActionText}"$)
    If Index < 0 Or Index >= CustomListView1.Size Then Return False
    Dim item As CLVItem = CustomListView1.GetRawListItem(Index)
    If Not(item.Value Is SwipeItem) Then Return False
    Dim m As SwipeItem = item.Value
    Dim mmap As Map = m.Value
    Log($"itemMap = ${mmap}"$)

    If ActionText = "Delete" Then
        CustomListView1.RemoveAt(Index)
    Else If ActionText = "Do Something Else" Then
        Dim p As B4XView = CustomListView1.GetPanel(Index)
        Dim lbl As B4XView = p.GetView(0)
        lbl.Text = "Done!!!"
    End If
End Sub
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
Action clicked: 3, Action 3
item = [Color=-1, IsInitialized=false, Offset=574
, Panel=(BALayout) anywheresoftware.b4a.BALayout{95ad215 VFE...CL. ........ -1056,574-314,756 #14}, Size=182, TextItem=true
, Value=[Actions=(ArrayList) [Action 1, Action 2, Action 3], IsInitialized=true, IsSwiped=false
, MaxSwipe=1056, Open=false, Value={Test=0, Test2=62}
]]
itemMap = {Test=0, Test2=62}
 
Last edited:

Tasyo28

Member
Licensed User
XView = CustomListVi
B4X:
Sub Swipe_ActionClicked (Index As Int, ActionText As String)
    Log($"Action clicked: ${Index}, ${ActionText}"$)
    If Index < 0 Or Index >= CustomListView1.Size Then Return False
    Dim item As CLVItem = CustomListView1.GetRawListItem(Index)
    If Not(item.Value Is SwipeItem) Then Return False
    Dim m As SwipeItem = item.Value
    Dim mmap As Map = m.Value
    Log($"itemMap = ${mmap}"$)

    If ActionText = "Delete" Then
        CustomListView1.RemoveAt(Index)
    Else If ActionText = "Do Something Else" Then
        Dim p As B4XView = CustomListView1.GetPanel(Index)
        Dim lbl As B4XView = p.GetView(0)
        lbl.Text = "Done!!!"
    End If
End Sub
Hi DonManfred,

Thanks for reply, based in your example the value result is Value={Test=0,Test2=75} how to extract this values and assign them to variables.

example:
dim Test as int = 0
dim Test2 as int = 75

Please advise what command need to use.
 
Top