Android Question (Typeface) Not initialized

fbritop

Active Member
Licensed User
Longtime User
I have the folowing error:
java.lang.RuntimeException: Object should first be initialized (Typeface).

But typeface does not have an init method. What is the correct way?


Starter Service
B4X:
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.   

   Public bigSize As Int=(19)
   Public superBigSize As Int=(24)
   Public titleSize As Int=(16)
   Public subTitleSize As Int=(14)
   Public smallSize As Int=(11)
   Public badgeSize As Int=(10)

   Public fontNormal, fontBold, fontBold2, fontMedium As Typeface
End Sub

Sub Service_Create
   
   fontNormal.LoadFromAssets("RobotoLight.ttf")
   fontBold.LoadFromAssets("RobotoRegular.ttf")
   fontBold2.LoadFromAssets("RobotoBlack.ttf")
   fontMedium.LoadFromAssets("RobotoMedium.ttf")
End Sub
Main.bas
B4X:
Log(fontBold)
cs.Initialize().Size(Starter.bigSize).Typeface(Typeface.MATERIALICONS).RelativeSize(0.8).Append(Chr(0xE551)).PopAll
cs.Size(Starter.bigSize).Typeface(Starter.fontBold).Append(" " & x.formatMobileNumberLong(Starter.kvs2.Get("movil"))).PopAll
ActionBar.Title=cs
 

sorex

Expert
Licensed User
Longtime User
try putting the typeface declarations and code in the Main.bas module.
 
Upvote 0

fbritop

Active Member
Licensed User
Longtime User
Same problem. if I use
B4X:
fontNormal = Typeface.CreateNew(Typeface.LoadFromAssets("RobotoLight.ttf"), Typeface.STYLE_NORMAL)

it works but does not load the font correctly
 
Upvote 0
Top