Android Question [solved] cannot create b4xFont

Pflichtfeld

Active Member
Licensed User
Try for a while to draw text to a canvas. Issue is the font object.
Erel writes in https://www.b4x.com/guides/B4xXUI/?page=20
xLabelFont = xui.CreateDefaultFont(16)
But I have no XUI-class, although the XUI-Lib (and XUI Views)is loaded

I declared it: Dim fnt As B4XFont
fnt=xui... does not react, means xui is not offered.
fnt.ToNativeFont makes no text-output at all.
Where is my fault?
 

Pflichtfeld

Active Member
Licensed User
Thanks Erel, I
I tried it with
B4X:
Public xui As XUI
or with
B4X:
Private xui As XUI
in Starter, Process_Globals, as you recommend. But it does not work.
Noticed now, that it works, when I add it in
Main, Process_Globals, what I do not understand.
 
Upvote 0

Pflichtfeld

Active Member
Licensed User
Why does it not work, when I add it as Public in starter, Process_Globals ? It should thus be available everywhere, isn't it? (but ist not)
 
Upvote 0

Pflichtfeld

Active Member
Licensed User
B4X:
lbl.Font = Starter.XUI.CreateFont(...)

Thanks again Erel!
As a newbie in b4x I've been reading and watching so much now and I thought, I had read (or heard) that global variables should be declared in Starter Process_Globals and that these (only these) are available everywhere without adding the module-name ('starter')
But it seems, I remember that wrong!
Maybe I am confused, because types are dealt in another way:
Types, declared in Starter Process_Globals are visible without the starter-module-name:
B4X:
Sub Process_Globals
    Type Mypkt(x As Float,y As Float,isError As Boolean)
    Public xui As XUI
    Public isItVisibleEverywhere As String
End Sub
is in a sub in Main available as
B4X:
Sub drawGrindEdge(pan As B4XView, alpha As Float, onebevel As Boolean)
    Dim canv As B4XCanvas
    Dim pkt (5) As Mypkt
    Dim pHelp As Mypkt
And
B4X:
Sub drawGrindEdge(pan As B4XView, alpha As Float, onebevel As Boolean)
    Dim canv As B4XCanvas
    Dim pkt (5) As Mypkt
    Dim pHelp As Starter.Mypkt    'is wrong
is wrong

Got it now. Thank you.
 
Last edited:
Upvote 0
Top