Android Question How can I add a new event in xCustomListView?

Myr0n

Active Member
Licensed User
Longtime User
Hello
As far as I know xCustomListView now is included as internal library (lib version 1.67) but a not long time ago was a custom view until version 1.66.

My question is, how can I add an #Event: ItemLongClick (Index As Int, Value As Object) and use it in my app since there is not included the source code here -> [B4X] [XUI] xCustomListView - cross platform CustomListView?

Thank you.
 

Myr0n

Active Member
Licensed User
Longtime User
You know, first, it's very hard to read what you post in plain text, you shoud post it using code tag
B4X:
Like this
Second, you should created a new thread with your question to help others that are having the same problem.
Third, you shoud debug your app and just before to add items to your LV add a break to see the execution of the code step by step.
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Upvote 0

Myr0n

Active Member
Licensed User
Longtime User
Upvote 0

Myr0n

Active Member
Licensed User
Longtime User
Nevermind I'll try the related post where you point me out

Thank you
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
If need be you can look at the first post in the link @Myron as that is how I actually do it when it comes to Android devices, but I sent you to Erels response as that is how it should be done.

In B4J there is not LongClick so I use a double click just like in Windows.
 
Upvote 0

Myr0n

Active Member
Licensed User
Longtime User
This is what I did to solve this:
I add this code where I am using the CLV, unfortunate the var PressedColor is not accesible, that's why I declared in my sub.

B4X:
Sub CreateListItem(Text As String, Width As Int, Height As Int) As Panel
    Dim p As Panel
    p.Initialize("Panel") '<---I add the eventname Panel here
    p.SetLayout(0, 0, Width, Height)
    p.LoadLayout("CellItem")
    Label1.Text = Text
    Return p
End Sub

Sub clv_ItemLongClick (Index As Int, Value As Object)
   log("You pressed the Long click")
End Sub

Private Sub PanelLongClickHandler(SenderPanel As B4XView)
    Dim clr As Int = clv.GetRawListItem(SenderPanel.Tag).Panel.Color
    Dim PressedColor As Int = 0xFF7EB4FA
    Dim EventName As String = "clv"
    SenderPanel.SetColorAnimated(50, clr, PressedColor)
    If xui.SubExists(Me, EventName & "_ItemLongClick", 2) Then
        CallSub3(Me, EventName & "_ItemLongClick", SenderPanel.Tag, clv.GetRawListItem(SenderPanel.Tag).Value)
    End If
    Sleep(200)
    SenderPanel.SetColorAnimated(200, PressedColor, clr)
End Sub

#If B4A
Private Sub Panel_LongClick
    PanelLongClickHandler(clv.GetRawListItem(clv.GetItemFromView(Sender)).Panel)
End Sub
#Else If B4i
    Private Sub Panel_LongClick
        PanelLongClickHandler(Sender)
    End Sub
#Else If B4J
'    Private Sub Panel_MouseLongClicked (EventData As MouseEvent)
'        PanelLongClickHandler(Sender)
'    End Sub
#End If


Thank you so much
 
Last edited:
Upvote 0

Myr0n

Active Member
Licensed User
Longtime User
Hello

unfortunately the previous post fix the long click but disabled all the rest of the events, like click, Reachend and scrollchanged.

Can you tell me someone what did I miss? please

I am attaching a test project with the longclick enabled but the rest of the events are disabled.
 

Attachments

  • xCustomListView Using Lib.zip
    12.7 KB · Views: 300
Last edited:
Upvote 0
Top