Android Question [SOLVED]Sender for B4XView switch view

giggetto71

Active Member
Licensed User
Longtime User
Hi guys,
I have got a Custom List view made with cards. Each card has several views insiede. By using the following code in the click event of the views I can get the index of the card where the view get clicked (below for example the code executed when I click on a conventional image view inside the card.

B4X:
Sub imgAlertCardStatus_Click
    
    Dim index As Int = CLV1.GetItemFromView(Sender)

Now, among the view I need to interact with, I have a B4xSwitch view, but using the same code the GetItemFromView crashes.

B4X:
Sub swEnable_ValueChanged (Value As Boolean)
    
    Dim index As Int = CLV1.GetItemFromView(Sender)

Below, the log I get:

Error occurred on line: 1783 (Main)
java.lang.ClassCastException: gigiosoft.MQTTAlert.b4xswitch cannot be cast to android.view.View
at anywheresoftware.b4a.objects.B4XViewWrapper.asViewWrapper(B4XViewWrapper.java:69)
at anywheresoftware.b4a.objects.B4XViewWrapper.getParent(B4XViewWrapper.java:166)
at b4a.example3.customlistview._getitemfromview(customlistview.java:411)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA$2.run(BA.java:370)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7078)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)

Any idea?




at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
 
Top