Android Question B4XPage Error nullpointerexception to set text a bbLabel [SOLVED]

netsistemas

Active Member
Licensed User
Longtime User
Attach a sample with error: (ATTACHED)
For view the error, uncomment the line under this line:
'error in this line : NullPointerException

Library references: XCustomListview 1.73 (1.72 en b4a) and BcTextEngine (1.81)

the error is about set bctextingine to a bblabel.


B4X:
#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
#End Region

'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip

Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI

    Type TD_Linea(IdInt  As Int, Customer As String )

    Private BBLabel1 As BBLabel
    Private CustomListView1 As CustomListView
    Private Label1 As Label
    Dim TextEngine As BCTextEngine


End Sub

Public Sub Initialize

End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    TextEngine.Initialize(Root)

    CargarItems

End Sub

'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.

Sub Button1_Click
    xui.MsgboxAsync("Hello world!", "B4X")
End Sub


private Sub CargarItems

    For f = 1 To 10
        Dim Lin As TD_Linea
        Lin.Customer = "Cliente " & f
        Lin.IdInt = f
        CustomListView1.Add(CreateListItem(Lin, CustomListView1.AsView.Width, 60dip),  Lin)
    Next

End Sub




Sub CreateListItem(Linea As TD_Linea ,Width As Int, Height As Int) As B4XView' Panel
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0, Width, Height)
    p.LoadLayout("LayoutChildren")
    p.Tag = Linea

    Label1.Text = Linea.IdInt


    'error in this line : NullPointerException
'    BBLabel1.Text = "[FontAwesome=0xF17B size=30/][b][color=0xff006688] Nº DOCUMENTO: " &  Linea.Customer  & "[/color][/b] "


    Return p
End Sub

I'm sure that is a stupid and easy solution, but...
 

Attachments

  • DemoBcEngine.zip
    9.5 KB · Views: 136
Last edited:

netsistemas

Active Member
Licensed User
Longtime User
Solution.
'set this before:


BBLabel1.TextEngine = TextEngine


when i do the loadlayout, the textengine ARE NOT loaded..
 
Upvote 0
Top