Android Question [Solved] How to disable a XUI CustomDialogs button?

JakeBullet70

Well-Known Member
Licensed User
Longtime User
Trying to disable a button the XUI CustomDialogs
All works just fine except it tosses an error when trying to disable the 'positive' button
Is it a bug or am I clueless? ;)


B4X:
    dialog.Initialize(mainObj.Root)
    dialog.Title = "Connection Options"
    #if b4j
    btnGetOctoKey.Visible = False
    #end if
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0,  400dip, 320dip)
    p.LoadLayout("dlgPrinterSetup")
    #if b4a
    dialog.PutAtTop = True 'put the dialog at the top of the screen
    #end if
    Try
        dialog.SetButtonState(xui.DialogResponse_Positive,False) '--- this tosses the error ***********************
    Catch
        Log(LastException) ' see below for exception
    End Try
    Wait For (dialog.ShowCustom(p, "OK", "", "Cancel")) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive And ValidConnection Then
        Save_settings
    End If

B4X:
Error occurred on line: 213 (B4XDialog)
java.lang.RuntimeException: Object should first be initialized (B4XView).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
    at anywheresoftware.b4a.objects.B4XViewWrapper.getViewObject(B4XViewWrapper.java:102)
    at anywheresoftware.b4a.objects.B4XViewWrapper.asPanelWrapper(B4XViewWrapper.java:105)
    at anywheresoftware.b4a.objects.B4XViewWrapper.GetAllViewsRecursive(B4XViewWrapper.java:305)
    at sadLogic.OctoTS.b4xdialog._getbutton(b4xdialog.java:1233)
    at sadLogic.OctoTS.b4xdialog._setbuttonstate(b4xdialog.java:90)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
    at sadLogic.OctoTS.popupprintersetup._show(popupprintersetup.java:88)
    at sadLogic.OctoTS.pageoptions._btneditprinter_click(pageoptions.java:126)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    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:4780)
    at android.view.View$PerformClick.run(View.java:19866)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5254)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
(Exception) java.lang.Exception:  java.lang.RuntimeException: Object should first be initialized (B4XView).
 
Top