Hi
I am unsure why this produces a runtime fatal error. I'm trying to delete a row within a custom list view
Log error is:
Row clicked with Index 0 and Value 0
Error occurred on line: 564 (Main)
java.lang.ClassCastException: android.app.AlertDialog cannot be cast to android.view.View
at anywheresoftware.b4a.objects.B4XViewWrapper.asViewWrapper(B4XViewWrapper.java:88)
at anywheresoftware.b4a.objects.B4XViewWrapper.getParent(B4XViewWrapper.java:185)
at b4a.example3.customlistview._getitemfromview(customlistview.java:413)
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.raiseEvent(BA.java:193)
at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:22)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:267)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.keywords.Common$1.onClick(Common.java:490)
at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:184)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7050)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
where line 564 is the .GetItemFromView(sender) in the listview line
Any ideas? I have this exact code working fine in another application. I don't believe that I've done anything different here...
Thanks,
Azhar
I am unsure why this produces a runtime fatal error. I'm trying to delete a row within a custom list view
B4X:
Sub lblDelete_Click
Dim result As Int
'check if user really wants to delete
Msgbox2Async("Are you sure?", "Delete Entry", "Yes", "Cancel", "No", Null, False)
Wait For Msgbox_Result (result As Int)
If result = DialogResponse.POSITIVE Then
Dim index As Int = xListView1.GetItemFromView(Sender)
'delete entry
xListView1.RemoveAt(index)
're-analyse
analyseRecalls
End If
End Sub
Log error is:
Row clicked with Index 0 and Value 0
Error occurred on line: 564 (Main)
java.lang.ClassCastException: android.app.AlertDialog cannot be cast to android.view.View
at anywheresoftware.b4a.objects.B4XViewWrapper.asViewWrapper(B4XViewWrapper.java:88)
at anywheresoftware.b4a.objects.B4XViewWrapper.getParent(B4XViewWrapper.java:185)
at b4a.example3.customlistview._getitemfromview(customlistview.java:413)
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.raiseEvent(BA.java:193)
at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:22)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:267)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.keywords.Common$1.onClick(Common.java:490)
at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:184)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7050)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
where line 564 is the .GetItemFromView(sender) in the listview line
Any ideas? I have this exact code working fine in another application. I don't believe that I've done anything different here...
Thanks,
Azhar