Customlistview Longclick?

m643

Member
Licensed User
Longtime User
Hi,

I'm using the customlistview. Is there also the possibility to use the Longclick and show a menu? I can't this in the documentation.

Michael
 

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Hello @m643 ,
have you solved this thread? Can you please post your code?
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
In the CustomListView class duplicate the Panel_Click Sub .. and change event name & parameter strings.
B4X:
Private Sub Panel_LongClick
 
   If SubExists(CallBack, EventName & "_LongClick") Then       
     Dim v As View
     v = Sender
     CallSub3(CallBack, EventName & "_LongClick", v.Tag, items.Get(v.Tag))
   End If
 
End Sub

Then in your Main module ..
B4X:
Sub clv1_LongClick (Index As Int,Value As Object)
 
Upvote 0

Shay

Well-Known Member
Licensed User
Longtime User
Hi
I did the above, and once I press long click I am getting:


java.lang.Exception: Sub clv3_longclick signature does not match expected signature.


at anywheresoftware.b4a.BA.raiseEvent2(BA.java:177)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:163)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:159)
at anywheresoftware.b4a.objects.ViewWrapper$2.onLongClick(ViewWrapper.java:87)
at android.view.View.performLongClick(View.java:4268)
at android.widget.TextView.performLongClick(TextView.java:8309)
at android.view.View$CheckForLongPress.run(View.java:17277)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4921)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)


at dalvik.system.NativeStart.main(Native Method)
java.lang.Exception: Sub clv3_longclick signature does not match expected signature.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
clv3_longclick signature does not match expected signature.
what IS the signature of your sub? Help us (giving more informations (code)) to help you
 
Upvote 0

Shay

Well-Known Member
Licensed User
Longtime User
You mean this?
B4X:
Sub clv3_LongClick (Index As Int,Value As Object)
Log("OK")
End Sub
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Shay .. just to be sure , can you post the class Panel_Longclick sub.
 
Upvote 0

Shay

Well-Known Member
Licensed User
Longtime User
Did Copy & Paste from the above
B4X:
Private Sub Panel_LongClick
   If SubExists(CallBack, EventName & "_LongClick") Then      
     Dim v As View
     v = Sender
     CallSub3(CallBack, EventName & "_LongClick", v.Tag, items.Get(v.Tag))
   End If
End Sub

But now - this is strange: I put the same code on "CustomListView" example project and it is working fine
How can it be?
 
Upvote 0

Shay

Well-Known Member
Licensed User
Longtime User
I found some clue, if I do this, it will not crash:
B4X:
Sub clv3_LongClick
Log("OK")
End Sub

so what can it be?
 
Upvote 0

Shay

Well-Known Member
Licensed User
Longtime User
This is in the class: (as written in the example above)
B4X:
Private Sub Panel_LongClick
   If SubExists(CallBack, EventName & "_LongClick") Then      
     Dim v As View
     v = Sender
     CallSub3(CallBack, EventName & "_LongClick", v.Tag, items.Get(v.Tag))
   End If
End Sub

and this is in my activity:
B4X:
Sub clv3_LongClick (Index As Int,Value As Object)
Log("OK")
End Sub

And as I said if I change it (in my activity) to:
B4X:
Sub clv3_LongClick
Log("OK")
End Sub

it is not crashing, so how do I fix it?

Thanks
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Shay .. your code looks OK and it should work.. ?
picking at straws ... does your module contain a normal click sub ... and it works as expected ?
B4X:
clv3_ItemClick (Index As Int, Value As Object)
 
Upvote 0

Shay

Well-Known Member
Licensed User
Longtime User
Ok, I found the issue
I had label which is init as: Label1.Initialize("clv3")
(I did this since I used other listView and I wanted to have same trigger as clv3)
so once I changed the name of the above label, now it is ok

strange thing that ItemClick had no issue, only the LongClick
 
Upvote 0
Top