Android Question error moving code from B4i to B4a, error

omarruben

Active Member
Licensed User
Longtime User
I have an app create in B4i and works without error

B4X:
Sub Class_Globals
    Private Root As B4XView 'ignore
    Private xui As XUI 'ignore
    Private clvListVideos As CustomListView                    '<------ variable declared, but not initialized anywere, by the example code
    Private PCLV As PreoptimizedCLV
    Private MediaManager As SimpleMediaManager
    'Type MyVideoData (title As String,descriptionVideo As String,filename As String)
End Sub

Sub showListVideos
    MediaManager.Initialize
 
    PCLV.Initialize(Me, "PCLV", clvListVideos)                         '<-----  error detected on this part
 
    For i = 0 To listVideos.Size-1
        PCLV.AddItem(350dip, xui.Color_White, listVideos.Get(i))
        Log(listVideos.Get(i))
    Next
    PCLV.ShowScrollBar = False 'no fast scrolling
    'PCLV.ExtraItems = 3
    PCLV.Commit
 
End Sub


I am trying to move to B4a but I have this error :

Logger connected to: motorola moto g power 5G - 2023
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
*** Receiver (httputils2service) Receive (first time) ***
Error occurred on line: 36 (PreoptimizedCLV)
java.lang.RuntimeException: Object should first be initialized (JavaObject).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
at anywheresoftware.b4j.object.JavaObject.getCurrentClass(JavaObject.java:259)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:119)
at com.hightechstream.kantutacreator.preoptimizedclv._initialize(preoptimizedclv.java:211)
at com.hightechstream.kantutacreator.b4xlistrequests._showlistvideos(b4xlistrequests.java:825)
at com.hightechstream.kantutacreator.b4xlistrequests$ResumableSub_loadListVideosFromServer.resume(b4xlistrequests.java:208)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
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:157)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:275)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:150)
at anywheresoftware.b4a.BA$2.run(BA.java:395)
at android.os.Handler.handleCallback(Handler.java:984)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loopOnce(Looper.java:238)
at android.os.Looper.loop(Looper.java:357)
at android.app.ActivityThread.main(ActivityThread.java:8088)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:957)

what should do to fix it, the original code is copied by an example on the post:



any help would be greatly appreciated
 
Last edited:

omarruben

Active Member
Licensed User
Longtime User
found the error, sorry again, when I copied the B4i layout from the designer I pasted the wrong one on the B4A layout
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…