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

Discussion in 'Android Questions' started by Myr0n, Jan 24, 2019.

  1. Myr0n

    Myr0n Active Member Licensed User

    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.
  2. Myr0n

    Myr0n Active Member Licensed User

    You know, first, it's very hard to read what you post in plain text, you shoud post it using code tag
    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.
  3. Peter Simpson

    Peter Simpson Expert Licensed User

  4. Myr0n

    Myr0n Active Member Licensed User

  5. Myr0n

    Myr0n Active Member Licensed User

    Nevermind I'll try the related post where you point me out

    Thank you
    Peter Simpson likes this.
  6. Peter Simpson

    Peter Simpson Expert Licensed 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.
  7. Myr0n

    Myr0n Active Member Licensed 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.

    Sub CreateListItem(Text As String, Width As Int, Height As Int) As Panel
    Dim p As Panel
    "Panel"'<---I add the eventname Panel here
        p.SetLayout(00, Width, Height)
        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"
    50, clr, PressedColor)
    If xui.SubExists(Me, EventName & "_ItemLongClick"2Then
    CallSub3(Me, EventName & "_ItemLongClick", SenderPanel.Tag, clv.GetRawListItem(SenderPanel.Tag).Value)
    End If
    200, PressedColor, clr)
    End Sub

    #If B4A
    Private Sub Panel_LongClick
    End Sub
    #Else If B4i
    Private Sub Panel_LongClick
    End Sub
    #Else If B4J
    '    Private Sub Panel_MouseLongClicked (EventData As MouseEvent)
    '        PanelLongClickHandler(Sender)
    '    End Sub
    #End If

    Thank you so much
    Last edited: Jan 24, 2019
  8. Myr0n

    Myr0n Active Member Licensed User


    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.

    Attached Files:

    Last edited: Jan 25, 2019
  9. Erel

    Erel Administrator Staff Member Licensed User

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice