Hello,
While trying to run the code in b4xpages I am facing the below error as follows :
The below is the code base :
Please advice
While trying to run the code in b4xpages I am facing the below error as follows :
B4X:
Activity (main) Resume **
Error occurred on line: 56 (B4XMainPage)
java.lang.RuntimeException: java.lang.RuntimeException: Object should first be initialized (Button).
Did you forget to call Activity.LoadLayout?
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:134)
at anywheresoftware.b4a.objects.B4XViewWrapper.LoadLayout(B4XViewWrapper.java:311)
at b4a.example.b4xmainpage$ResumableSub_B4XPage_Created.resume(b4xmainpage.java:198)
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:144)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43)
at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1704)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6820)
at java.lang.reflect.Method.invoke(Native Method)
The below is the code base :
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
Log("create")
If Not(rp.Check(rp.PERMISSION_ACCESS_FINE_LOCATION)) Then
rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
End If
Root = Root1
Root.LoadLayout("splash2")
ImageView1.SetBitmap(xui.LoadBitmapResize(File.DirAssets, "welcome.png", ImageView1.Width, ImageView1.Height, True))
Sleep(1000)
cImei=GenerateID
If File.Exists(File.DirInternal, "Test.db") = False Then
SQL1.Initialize(File.DirInternal, "Test.db", True)
CreateDataBase
Else
SQL1.Initialize(File.DirInternal, "Test.db", True)
End If
cur= SQL1.ExecQuery("select * from test")
If cur.RowCount==0 Then
Root.LoadLayout("reg1") ===> getting error at this line
Else
cur.Position=0
cName=cur.GetString("name")
cPhone=cur.GetString("phone")
Root.LoadLayout("MainPage")
Wait For MapFragment1_Ready
gmap = MapFragment1.GetMap
gmap.GetUiSettings.ZoomControlsEnabled=False
gmap.MyLocationEnabled = True
gmap.TrafficEnabled=False
Do While gmap.MyLocation.IsInitialized = False
'Log("Location not initialized... Sleep a while...")
Sleep(250)
Loop
If gmap.MyLocation.IsInitialized Then
Dim CameraPosition1 As CameraPosition
gmap.MapType=gmap.MAP_TYPE_NORMAL
gmap.MyLocationEnabled = True
CameraPosition1.Initialize(gmap.MyLocation.Latitude,gmap.MyLocation.Longitude, 16)
gmap.MoveCamera(CameraPosition1)
End If
End If
cur.Close
End Sub
Please advice