Android Question B4XDialog crash on android 8.1

techgreyeye

Member
Licensed User
Longtime User
As per title...

It's crashing on

dialog.TitleBar.Height = 10%y


but only on my Oreo device (also test on android 10 and 13 devices)

Using B4A 11.8, XUIViews library version 2.55

B4A:
        Dim dialog As B4XDialog
        Dim input As B4XInputTemplate
        Dim xui As XUI
        Dim rs As Object
        dialog.Initialize(Activity)
        dialog.Title = "Import """ & i_prod_list(this_index).description & """ ?"
       
        input.Initialize
        input.lblTitle.Text = "Count "
        input.ConfigureForNumbers(True, False)
        input.GetPanel(dialog).Height = 30%y
        input.GetPanel(dialog).Width = 80%x
        input.lblTitle.SetTextAlignment("MIDDLE","LEFT")

        rs = dialog.ShowTemplate(input, "Yes with count", "Yes", "No")
        dialog.Resize(100%x,100%y)
        dialog.TitleBar.Height = 10%y
       
        Log(GetType( dialog.TitleBar))

        input.lblTitle.top = dialog.TitleBar.Top + dialog.TitleBar.Height
        input.lblTitle.SetTextAlignment("MIDDLE","LEFT")
        input.TextField1.Top = input.lblTitle.Top
        input.TextField1.Left = 20%x
        Wait For (rs) Complete (Result As Int)
        If Result = xui.DialogResponse_Positive Then



Log :

Log:
** Activity (import_product) Create, isFirst = true **
** Activity (import_product) Resume **
Error occurred on line: 599 (Import_Product)
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:91)
    at anywheresoftware.b4a.objects.B4XViewWrapper.setHeight(B4XViewWrapper.java:135)
    at gtl.stockmatef.import_product$ResumableSub_Cell_Click.resume(import_product.java:3853)
    at gtl.stockmatef.import_product._cell_click(import_product.java:3724)
    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:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:146)
    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:6294)
    at android.view.View$PerformClick.run(View.java:24774)
    at android.os.Handler.handleCallback(Handler.java:790)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6518)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)


Any ideas?

In addition, when I am trying to increase the height of the dialog title line, the background grows but the label within it does not. How do I resize the label?

EG using default size...

Screenshot_20230302_100818.jpg



EG after setting dialog.TitleBar.Height = 10%y

Screenshot_20230302_100847.jpg



EDIT: I've got the text resizing with the following :

Resize:
        dialog.TitleBar.GetView(0).Height = 10%y

but this line also causes a crash on Oreo.


Thanks for any help
 
Last edited:

techgreyeye

Member
Licensed User
Longtime User
Always use the latest version.

The title was probably removed because there isn't enough room for the keyboard.

Check that it is initialized before you access it:
B4X:
if   dialog.TitleBar.IsInitialized Then ...


Yes, that's what appears to be happening. Thanks.

(We only update version when necessary - we don't have enough testing resource to do the necessary when rebuilding with potential changes in libraries - and it's stung us in the past).
 
Upvote 0
Top