Android Question ERROR using B4XDialog

Hey

I'm using the same example of dialog.showtemplate in B4A for pressing Button10
I defined "options As B4XListTemplate" in Globals. Then initialize it after my layout has been loaded (which contains Button10) and put the options in options
B4X:
Activity.LoadLayout("Mobile")
options.Initialize
options.Options = Array("Cat", "Dog", "Fish", "Crocodile")
base=Activity
dlg.Initialize(base)

dlg and base have been defines as B4XDialog and B4XView in Globals and base=Activity.
in Button10 click event I put:
B4X:
Sub Button10_Click
    Wait For (dlg.ShowTemplate(options, "OK", "", "CANCEL")) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive Then
        dlg.Show($"You selected: ${options.SelectedItem}"$, "OK", "", "")
    End If
End Sub

I got three errors (in debugger) . first one happens when I click on Button10 but dialog will be shown and it is
1-java.lang.OutOfMemoryError

and the second and third ones happen when I choose one item (like "Dog" or click on ok or cancel) and they are
2-Error occurred on line: 174 (B4XDialog)
java.lang.RuntimeException: Unexpected command: 0

3-Error occurred on line: 174 (B4XDialog)
java.lang.ClassCastException: java.lang.String cannot be cast to anywheresoftware.b4a.shell.Shell$RemoteObject

does anybody have an idea what I did wrong?
 
No. You haven't provided enough information.

1. Start with a single problem.
2. Post the full error message.
3. If the project is small then upload the project.

Hey
thanks for your being supportive and helpful
1. As those are happening one after another I think to mention all together.
2. I made small project with all main elements and I must say it works properly. But when it comes to my main project I don't know why error is happening.
3. I put "Log("1")" and "Log("2)" before and after " Wait For" in "Button10_click"

B4X:
Sub Button10_Click
    Log("1")
    Wait For (dlg.ShowTemplate(options,"OK","","CANCEL")) Complete (Result As Int)
    Log("2")
    If Result = xui.DialogResponse_Positive Then
        Log("OK")
        Return
    End If
End Sub

"1" will be logged but "2" won't. It seems that something is happening in " Wait For". This is the first error I got by clicking on button10.

java.lang.OutOfMemoryError: Failed to allocate a 184559498 byte allocation with 16777216 free bytes and 169MB until OOM
at anywheresoftware.b4a.shell.ShellConnector.readObject(ShellConnector.java:281)
at anywheresoftware.b4a.shell.ShellConnector.readList(ShellConnector.java:222)
at anywheresoftware.b4a.shell.Shell.getStateAfterUserSub(Shell.java:513)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:414)
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.raiseEvent2(BA.java:197)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:5789)
at android.view.View$PerformClick.run(View.java:22724)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6125)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:893)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783)

4. After that dialog will be shown. By clicking on options ("Dog",...) this error will happen



Error occurred on line: 174 (B4XDialog)
java.lang.RuntimeException: Unexpected command: 108
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:426)
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.keywords.Common.CallSub4(Common.java:1082)
at anywheresoftware.b4a.keywords.Common.CallSubNew3(Common.java:1045)
at b4a.example3.customlistview$ResumableSub_PanelClickHandler.resume(customlistview.java:805)
at b4a.example3.customlistview._panelclickhandler(customlistview.java:748)
at b4a.example3.customlistview._panel_click(customlistview.java:735)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:5789)
at android.view.View$PerformClick.run(View.java:22724)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6125)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:893)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783)


I hope it would be enough
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…