Android Question CustomListView ItemLongClick?

Branko Milosevic

Active Member
Licensed User
I use CustomListView v1.50 library and found everything I need except the ItemLongClick. It know it needed to be added in the class in the past but I already use the library. Is there a newer version of the library with the long click event compiled in already?

Thanks?
 

Branko Milosevic

Active Member
Licensed User
I loaded CustomListView.bas and added the ItemLongClick event with this code. Long click event fires but no vibrate. My MsgBox2 pops up and it vibrates on a click on either button.
B4X:
Private Sub Panel_LongClick
    If SubExists(CallBack, EventName & "_ItemLongClick") Then
        Dim v As View
        v = Sender
        CallSub3(CallBack, EventName & "_ItemLongClick", v.Tag, items.Get(v.Tag))
    End If
End Sub

Here is my Msg2 call
B4X:
Sub clv1_ItemLongClick (Position As Int, value As Object)
    Dim result As Int
    result = Msgbox2("Remove Exercize", "", "Remove", "Cancel", "", Null)
   
    If result=DialogResponse.POSITIVE Then
        Log("remove clicked")
    Else
        Log("cancel clicked")
    End If
End Sub


When I apply same to a standard ListView it vibrates on a long click.
 
Upvote 0

Branko Milosevic

Active Member
Licensed User
I loaded CustomListView.bas and added the ItemLongClick event with this code. Long click event fires but no vibrate. My MsgBox2 pops up and it vibrates on a click on either button.


When I apply same to a standard ListView it vibrates on a long click.

I removed "vibrate" in the phone settings. Now the code crashes every time I long click on the item.
it works fine on a newer phone but on my test device which is v.2.3.4 GT-55830D it fires a long click briefly a click and a crash.
 
Upvote 0

Branko Milosevic

Active Member
Licensed User
Can you post the logs? It is better to use CallSubDelayed to raise the event.

Here is my code with added log()'s
B4X:
Sub clv1_ItemLongClick (Position As Int, value As Object)
    Dim result As Int
   
        Log("longclick")
    'Wait(1000)
    result =Msgbox2("Remove Exercize", "", "Remove", "Cancel", "", Null)
   
        Log("after message box pop up")
   
    If result=DialogResponse.POSITIVE Then
        Log("remove clicked")
    Else
        Log("cancel clicked")
    End If
   
    Wait(2000)
    Log("exiting long click dialog")
End Sub

Long clicked twice, first time worked OK crashed on the second long click:

B4X:
** Activity (currentsession) Resume **
longclick
after message box pop up
cancel clicked
exiting long click dialog
longclick
** Activity (currentsession) Pause, UserClosed = false **
 
Upvote 0

Branko Milosevic

Active Member
Licensed User
Here is the project. When you start click + on the main screen to add a new file, then when file is created click on it to open the screen/activity with the CLV. A click on an item opens edit popup. Long click opens the dialog with the delete option. It crashes on an older Samsung android 2.3.2 phone 8 out of 10 times.
 

Attachments

  • For Erel.zip
    22.2 KB · Views: 277
Upvote 0
Top