Bug? What is it that needs to be initialized?

Lee Gillie CCP

Active Member
Licensed User
Longtime User
Help!

The routine I am debugging:
Public Sub AddToParent(Parent As B4XView, Left As Int, Top As Int, Width As Int, Height As Int)
    Log($"SearchView2.AddToParent: clv.IsInitialized=${clv.IsInitialized}"$)
    mParent = Parent

    Log($"Parent.IsInitialized = ${Parent.IsInitialized}"$)
    Log($"holder.IsInitialized = ${holder.IsInitialized}"$)
    Log($"et.IsInitialized = ${et.IsInitialized}"$)
    Log($"clv.IsInitialized = ${clv.IsInitialized}"$)
    Log($"clv.AsView.IsInitialized = ${clv.AsView.IsInitialized}"$)
    Log("There is no way to initialize clv.AsView")
    ' Create a host panel first; only then add inner views.
    mParent.AddView(holder, Left, Top, Width, Height)
    holder.Color = Colors.Transparent

    holder.AddView(et, 0, 0, Width, 60dip)
    ' The following crashes:
    holder.AddView(clv.AsView, 0, et.Height, Width, Height - et.Height)

    clv.AsView.Visible = False   ' safe now (already parented)
End Sub

What this logs:
** Activity (editline) Create (first time) **
SearchView2.Initialize: is engine initialized ? true
SearchView2.AddToParent: clv.IsInitialized=true
Parent.IsInitialized = true
holder.IsInitialized = true
et.IsInitialized = true
clv.IsInitialized = true
clv.AsView.IsInitialized = false
There is no way to initialize clv.AsView
Error occurred on line: 57 (SearchView2)
java.lang.RuntimeException: Object should first be initialized (B4XView).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
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)

Screenshot 2025-10-24 123544.png


It makes no sense to me!

TIA for any ideas - Best regards, Lee Gillie, CCP
 

Lee Gillie CCP

Active Member
Licensed User
Longtime User
you don't need the .asView suffix, just use clv

Cableguy - Thank you for responding

I tried just passing clv, but now it does this...
clv.IsInitialized = true
clv.AsView.IsInitialized = false
There is no way to initialize clv.AsView
Error occurred on line: 57 (SearchView2)
java.lang.IllegalArgumentException: method anywheresoftware.b4a.objects.PanelWrapper.AddView argument 1 has type android.view.View, got b4a.example3.customlistview
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
at odp.eljaydelivery.searchview2._addtoparent(searchview2.java:120)
 

Cableguy

Expert
Licensed User
Longtime User
remove any ".asView" you have on your code, you don't need that and it doesn't work!
 
Top