M miling Member Jun 3, 2026 #1 I want to create a SwiftButton and add it to an activity, but I'm getting an error. B4X: Copy Dim btBackLevelUp As SwiftButton btBackLevelUp.Initialize(Me,"btBackLevelUp") Activity.AddView(btBackLevelUp.mBase,0,Activity.Height-60,Activity.Width,Activity.Height) error: B4X: Copy Error occurred on line: 95 (Home) 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) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:205) at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262) at b4a.example.s1.home._levelup(home.java:921) at b4a.example.s1.home._button4_click(home.java:907) 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.raiseEvent2(BA.java:205) at anywheresoftware.b4a.BA.raiseEvent(BA.java:201) at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80) at android.view.View.performClick(View.java:7745) at android.view.View.performClickInternal(View.java:7722) at android.view.View.access$3700(View.java:854) at android.view.View$PerformClick.run(View.java:29111) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:210) at android.os.Looper.loop(Looper.java:299) at android.app.ActivityThread.main(ActivityThread.java:8319) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:556) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1038) ** Activity (home) Pause, UserClosed = true **
I want to create a SwiftButton and add it to an activity, but I'm getting an error. B4X: Copy Dim btBackLevelUp As SwiftButton btBackLevelUp.Initialize(Me,"btBackLevelUp") Activity.AddView(btBackLevelUp.mBase,0,Activity.Height-60,Activity.Width,Activity.Height) error: B4X: Copy Error occurred on line: 95 (Home) 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) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:205) at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262) at b4a.example.s1.home._levelup(home.java:921) at b4a.example.s1.home._button4_click(home.java:907) 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.raiseEvent2(BA.java:205) at anywheresoftware.b4a.BA.raiseEvent(BA.java:201) at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80) at android.view.View.performClick(View.java:7745) at android.view.View.performClickInternal(View.java:7722) at android.view.View.access$3700(View.java:854) at android.view.View$PerformClick.run(View.java:29111) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:210) at android.os.Looper.loop(Looper.java:299) at android.app.ActivityThread.main(ActivityThread.java:8319) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:556) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1038) ** Activity (home) Pause, UserClosed = true **
Solution Erel Jun 4, 2026 1. Switch to B4XPages. Don't waste time with activities. 2. Use the designer to create the layout. There are several mistakes in the short code your posted. 3. SwiftButton, like most custom views, must be added with the designer.
1. Switch to B4XPages. Don't waste time with activities. 2. Use the designer to create the layout. There are several mistakes in the short code your posted. 3. SwiftButton, like most custom views, must be added with the designer.
Erel B4X founder Staff member Licensed User Longtime User Jun 4, 2026 #2 1. Switch to B4XPages. Don't waste time with activities. 2. Use the designer to create the layout. There are several mistakes in the short code your posted. 3. SwiftButton, like most custom views, must be added with the designer. Upvote 0 Solution
1. Switch to B4XPages. Don't waste time with activities. 2. Use the designer to create the layout. There are several mistakes in the short code your posted. 3. SwiftButton, like most custom views, must be added with the designer.