Android Question [RESOLVED] how can I create a BBLabel by code, without using the designer?

Lucas Siqueira

Active Member
Licensed User
how can I create a BBLabel by code, without using the designer?

I want to add it to a panel, and put a text in BBLabel on it, I've tried it in many ways, but it always says you need to initialize ...

if i do it via designer it works blz, but in my case i will need it via code, because i will build a customview class ...

Could someone post a code thread?
I visited several topics, including: https://www.b4x.com/android/forum/threads/how-to-add-bblabel-bbcode-by-code.115051/, but unfortunately I couldn't make it work ...: (


I tried, but to no avail.
B4X:
    Dim panel As B4XView = xui.CreatePanel("")
    panel.Color = xui.Color_Blue
    MainForm.RootPane.AddNode(panel,10,10,100,100)

    Dim bblabel As BBLabel
    bblabel.Initialize(panel,"bblabel")
    bblabel.TextEngine.Initialize(panel)
    bblabel.Paragraph.Initialize
    bblabel.Text=$"[FontAwesome=0xF17B size=30/] This is a [b]BB[color=0xff006688]Label[/color][/b]"$

[LOG]
bblabel._parseanddraw (java line: 169)
java.lang.RuntimeException: Object should first be initialized (B4XView).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:32)
at anywheresoftware.b4a.objects.B4XViewWrapper.asPaneWrapper(B4XViewWrapper.java:133)
at anywheresoftware.b4a.objects.B4XViewWrapper.getNumberOfViews(B4XViewWrapper.java:543)
at b4j.example.bblabel._parseanddraw(bblabel.java:169)
at b4j.example.bblabel._settext(bblabel.java:237)
at b4j.example.main._appstart(main.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at b4j.example.main.start(main.java:37)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
at java.lang.Thread.run(Thread.java:748)
[/LOG]
 
Last edited:
Top