B4J Question Paint fail to initialise ?

hookshy

Well-Known Member
Licensed User
Longtime User
I have a process variable
B4X:
dim pipecolor as paint    pipecolor= fx.Colors.Blue

and I face sometimes the problem when using its variable like
object should be first initialised paint ...on this line :
lbl(newindex).TextColor=pipecolor

when I try to fix this with :

B4X:
If pipecolor.IsInitialized=False Then
    pipecolor=fx.Colors.Blue
End If
I get null pointer exception error ...

How should I handle this paint object to skip initialisation errors ?
 

Roycefer

Well-Known Member
Licensed User
Longtime User
I've run into that problem, too. I think the best solution is to store your "color" variables as Ints, as follows:
B4X:
Dim pipecolor As Int = fx.Colors.To32Bit(fx.Colors.Blue)
and then when you want to set a color of something, use:
B4X:
fx.Colors.From32Bit(pipecolor)
 
Upvote 0
Top