iOS Question Dialogs with B4i and B4A

pliroforikos

Active Member
Licensed User
Hello,
I'm trying to convert Β4Α dialog to B4i. But i have some trouble to make them identical.
Below on the left you can see iPhone dialog and right the Android one.

school.png


There are 3 float Text Fields in my code and the code is the same

B4A and B4i sub:
Private Sub showDialog
    dlgInsSchool.Initialize(Root)
    dlgInsSchool.Title = textDlgTitle

    dlgInsSchool.TitleBarColor = xui.Color_RGB(83,88,143)
    dlgInsSchool.TitleBarHeight = 50dip
    dlgInsSchool.BorderColor = xui.Color_RGB(83,88,143)
    dlgInsSchool.BorderCornersRadius = 10

    Dim p As B4XView = xui.CreatePanel("")
'    p = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0, 350dip, 260dip)
    p.LoadLayout("dlgSchool")
    dlgInsSchool.PutAtTop = True 'put the dialog at the top of the screen
   
    fltSchName.HintText = "School"
    fltSchName.HintColor = xui.Color_RGB(83,88,143)
    fltSchName.Update
   
    fltSchAddress.HintText = "Address"
    fltSchAddress.HintColor = xui.Color_RGB(83,88,143)
    fltSchAddress.Update
   
    fltPostOffice.HintText = "POB"
    fltPostOffice.HintColor = xui.Color_RGB(83,88,143)
    fltPostOffice.Update

    Dim rs As ResumableSub = dlgInsSchool.ShowCustom(p, textBtnOK, textBtnNo, textBtnCancel)
    fltSchName.RequestFocusAndShowKeyboard
'    Dim b As B4XView = dlgInsSchool.GetButton(xui.DialogResponse_Positive)
'    b.Height = 30dip
'    ValidateFields(fltSchName.Text, fltSchAddress.Text, fltSchKey.Text)
    Wait For (rs) Complete (result As Int)

    If result = xui.DialogResponse_Positive Then
        mSchool.Initialize
        mSchool.Put("schname", fltSchName.Text)
        mSchool.Put("url", fltSchAddress.Text)
        mSchool.Put("hash", fltPostOffice.Text)
    End If

End Sub


The worst thing is when i click ok button B4i program crash with this message.

Application_Start
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
Application_Active
Unexpected event (missing RaisesSynchronousEvents): b4ipage_keyboardstatechanged:
Error occurred on line: 275 (B4XFloatTextField)
Method not found: resumeAsUserSub, target: [_xui=<B4IXUI: 0x600001f64c80>, _buttonsheight=40, _titlebarheight=50
, _buttonwidth=80, _base=<B4XViewWrapper: <B4IPanelView: 0x7fb732740610; frame = (18 20; 354 356); clipsToBounds = YES; alpha = 0; hidden = YES; animations = { opacity=<CABasicAnimation: 0x600001d03620>; }; layer = <CALayer: 0x600001d52660>>>, _backgroundcolor=-11184811
, _overlaycolor=-1442840576, _bordercolor=-11315057, _bordercornersradius=10
, _borderwidth=2, _buttonscolor=-11184811, _buttonstextcolor=-7744001
, _background=<B4XViewWrapper: <B4IPanelView: 0x7fb73273fd80; frame = (0 0; 390 753); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x6000013417a0>; layer = <CALayer: 0x600001d5ffc0>>>, _blurimageview=<B4XViewWrapper: (null)>, _blurbackground=0
, _blurreducescale=3, _mparent=<B4XViewWrapper: <B4IPanelView: 0x7fb734013850; frame = (0 0; 390 753); layer = <CALayer: 0x600001d43940>>>, _title=Insert School
, _titlebarcolor=-11315057, _titlebartextcolor=-1, _bodytextcolor=-1
, _titlebar=<B4XViewWrapper: <B4IPanelView: 0x7fb732741090; frame = (2 2; 350 50); clipsToBounds = YES; layer = <CALayer: 0x600001d2c200>>>, _putattop=1, _titlebarfont=<B4XFont: <UICTFont: 0x7fb7327182e0> font-family: ".SFUI-Semibold"; font-weight: bold; font-style: normal; font-size: 16.00pt>
, _buttonsfont=<B4XFont: <UICTFont: 0x7fb73400ed60> font-family: ".SFUI-Semibold"; font-weight: bold; font-style: normal; font-size: 15.00pt>, _buttonstextcolordisabled=-8355712, _visibleanimationduration=100
, _buttonsorder=<B4IArray: 0x600001348000>, _buttonsstate=NSMapTable {
}
, _dateutils=<b4i_dateutils: (null)>
, _main=<b4i_main: (null)>, _b4xpages=<b4i_b4xpages: (null)>, _b4xcollections=<b4i_b4xcollections: (null)>
, _xuiviewsutils=<b4i_xuiviewsutils: (null)>]
Stack Trace: (
CoreFoundation __exceptionPreprocess + 242
libobjc.A.dylib objc_exception_throw + 48
CoreFoundation -[NSException initWithCoder:] + 0
myDialogs +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 342
myDialogs -[B4IShell runGoodChain::] + 330
myDialogs -[B4IShell raiseEventImpl:method:args::] + 2509
myDialogs -[B4IShellBI raiseEvent:event:params:] + 1358
myDialogs -[B4IDelegatableResumableSub resume::] + 375
myDialogs __21-[B4ICommon Sleep:::]_block_invoke + 45
libdispatch.dylib _dispatch_client_callout + 8
libdispatch.dylib _dispatch_continuation_pop + 482
libdispatch.dylib _dispatch_source_invoke + 2079
libdispatch.dylib _dispatch_main_queue_callback_4CF + 848
CoreFoundation __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
CoreFoundation __CFRunLoopRun + 2772
CoreFoundation CFRunLoopRunSpecific + 567
GraphicsServices GSEventRunModal + 139
UIKitCore -[UIApplication _run] + 928
UIKitCore UIApplicationMain + 101
myDialogs main + 104
dyld start_sim + 10
??? 0x0 + 4649776414
)

So:
1. How can i make to dialogs identical?
2. How to resolve this message?

Thank you very much for your support
 
Last edited:

Alexander Stolte

Expert
Licensed User
Longtime User
1. How can i make to dialogs identical?
If you want an identical TextField, then I recommend you my AS_TextFieldAdvanced, that looks the same on all 3 platforms, without you having to adjust anything.
 
Upvote 0

pliroforikos

Active Member
Licensed User
If you want an identical TextField, then I recommend you my AS_TextFieldAdvanced, that looks the same on all 3 platforms, without you having to adjust anything.

Thank you. I did this:

B4X:
Sub Class_Globals
    Private dlg2 As B4XDialog
    Private txt1 As AS_TextFieldAdvanced
    Private txt2 As AS_TextFieldAdvanced
    Private txt3 As AS_TextFieldAdvanced
' And more variables ...

end sub

'Other code...


Private Sub showDialog2
    dlg2.Initialize(Root)
    dlg2.Title = textDlgTitle

    dlg2.TitleBarColor = xui.Color_RGB(83,88,143)
    dlg2.TitleBarHeight = 50dip
    dlg2.BorderColor = xui.Color_RGB(83,88,143)
    dlg2.BorderCornersRadius = 10

    Dim p As B4XView = xui.CreatePanel("")
'    p = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0, 350dip, 260dip)
    p.LoadLayout("dlg2")
    dlg2.PutAtTop = True 'put the dialog at the top of the screen
    txt1.Hint.Text = "School"
    txt2.Hint.Text = "Address"
    txt3.Hint.Text = "POB"
    txt1.Refresh
    txt2.Refresh
    txt3.Refresh

    Dim rs As ResumableSub = dlg2.ShowCustom(p, textBtnOK, textBtnNo, textBtnCancel)

    Wait For (rs) Complete (result As Int)

    If result = xui.DialogResponse_Positive Then
        mSchool.Initialize
        mSchool.Put("schname", txt1.Text)
        mSchool.Put("url", txt2.Text)
        mSchool.Put("hash", txt3.Text)
    End If

End Sub

and of course i made the dlg2.bal with designer. But i'm getting the following error when i click on a button to show form:

** Activity (main) Pause event (activity is not paused). **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
as_textfieldadvanced_textchanged (java line: 1589)
java.lang.RuntimeException: Object should first be initialized (B4XView).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
at anywheresoftware.b4a.objects.B4XViewWrapper.asViewWrapper(B4XViewWrapper.java:89)
at anywheresoftware.b4a.objects.B4XViewWrapper.setVisible(B4XViewWrapper.java:115)
at b4a.myDialog.as_textfieldadvanced._textchanged(as_textfieldadvanced.java:1589)
at b4a.myDialog.as_textfieldadvanced._xtf_textfield_textchanged(as_textfieldadvanced.java:1689)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at anywheresoftware.b4a.objects.EditTextWrapper$1.afterTextChanged(EditTextWrapper.java:83)
at android.widget.TextView.sendAfterTextChanged(TextView.java:8267)
at android.widget.TextView.setText(TextView.java:4553)
at android.widget.TextView.setText(TextView.java:4343)
at android.widget.EditText.setText(EditText.java:89)
at android.widget.TextView.setText(TextView.java:4318)
at android.widget.TextView.setTransformationMethod(TextView.java:1942)
at android.widget.TextView.applySingleLine(TextView.java:7948)
at android.widget.TextView.setSingleLine(TextView.java:7923)
at anywheresoftware.b4a.objects.EditTextWrapper.setSingleLine(EditTextWrapper.java:140)
at b4a.myDialog.as_textfieldadvanced._createtextfield(as_textfieldadvanced.java:867)
at b4a.myDialog.as_textfieldadvanced._designercreateview(as_textfieldadvanced.java:916)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:67)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:134)
at anywheresoftware.b4a.objects.B4XViewWrapper.LoadLayout(B4XViewWrapper.java:312)
at b4a.myDialog.b4xmainpage$ResumableSub_showDialog2.resume(b4xmainpage.java:263)
at b4a.myDialog.b4xmainpage._showdialog2(b4xmainpage.java:227)
at b4a.myDialog.b4xmainpage._button2_click(b4xmainpage.java:67)
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:5653)
at android.view.View$PerformClick.run(View.java:22456)
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:6138)
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)
** Activity (main) Resume **
 
Upvote 0

pliroforikos

Active Member
Licensed User
Check B4XPreferencesDialog.

Thank you Erel. Until now i had B4XPreferencesDialog but i wanted a new "look" for my forms and i couldn't change colors for example Title Bar color or make dialog have rounded corners. Maybe i am wrong :oops:
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
Upvote 0
Top