Android Question [B4X] [XUI] xCustomListView - ItemLongClick missing

ivan.tellez

Active Member
Licensed User
Its really useful to have a secondary interaction, so I have to modify the class (Based on xCustomListView v1.64)

B4X:
#Event: ItemLongClick (Index As Int, Value As Object)


Private Sub PanelClickHandler(SenderPanel As B4XView, IsLong As Boolean)
    Dim clr As Int = GetRawListItem(SenderPanel.Tag).Color
    SenderPanel.SetColorAnimated(50, clr, PressedColor)
    If IsLong = False Then
        If xui.SubExists(CallBack, EventName & "_ItemClick", 2) Then
            CallSub3(CallBack, EventName & "_ItemClick", SenderPanel.Tag, GetRawListItem(SenderPanel.Tag).Value)
        End If
    Else
        If xui.SubExists(CallBack, EventName & "_ItemLongClick", 2) Then
            CallSub3(CallBack, EventName & "_ItemLongClick", SenderPanel.Tag, GetRawListItem(SenderPanel.Tag).Value)
        End If       
    End If
    Sleep(200)
    SenderPanel.SetColorAnimated(200, PressedColor, clr)
End Sub


#If B4A
Private Sub Panel_Click
    PanelClickHandler(Sender, False)
End Sub

Private Sub Panel_LongClick
    PanelClickHandler(Sender, True)
End Sub

#else If B4i

Private Sub Panel_Click
    PanelClickHandler(Sender, False)
End Sub

Sub Panel_LongClick
    PanelClickHandler(Sender, True)
End Sub

#else If B4J

Private Sub Panel_MouseClicked (EventData As MouseEvent)
    If EventData.PrimaryButtonPressed Then
        PanelClickHandler(Sender, False)
    Else If EventData.SecondaryButtonPressed Then
        PanelClickHandler(Sender, True)
    End If
End Sub

#End If

Tested on B4A and B4J should work on B4I


@Erel, can you implement the _ItemLongClick in the oficial xCustomListView, not shure if this approach is the best/correct way to do it.
 
Top