Android Question Custom view (child) view properties?

keb

New Member
Licensed User
Longtime User
I have created a custom view:

Sub Class_Globals
Private N, D As Long
Private lblN As Label
Private lblD As Label
End Sub

Public Sub DesignerCreateView(Base As Panel, lbl As Label, Props As Map)
lblN.Initialize("")
lblD.Initialize ("")
Base.AddView(lblN,0,0,Base.Width,Base.Height/2)
Base.AddView(lblD,0,Base.Height/2,Base.Width,Base.Height/2)
lblN.Color = Colors.Magenta
lblD.Color = Colors.Green
lblN.Gravity=Bit.OR(Gravity.CENTER_HORIZONTAL,Gravity.CENTER_VERTICAL)
lblN.Typeface=Typeface.DEFAULT
lblN.TextSize=48
lblN.TextColor=Colors.White
lblD.Gravity=lblN.Gravity
lblD.Typeface=lblN.Typeface
lblD.TextSize=lblN.TextSize
lblD.TextColor=Colors.Black
lblN.Text = "N"
lblD.Text = "D"
End Sub

this works fine, I see two labels with the correct attributes when the app runs. But

Public Sub setNum(nn As Long)
N = nn
lblN.Text = "n" <------ errors with ...RuntimeException: Object should first be initialized (Label).
End Sub

The class properties (N, D) work fine, both set and get, when that line is taken out so I'm pretty sure the instantiation, initializing and usage are correct. But the lblN seems to be unavailable outside DesignerCreateView ?!?!?!

I have VB6 experience, with classes and custom controls, but maybe in B4A (child) views properties are not available at all and it has nothing to do with classes or custom views?

Thank you
 
Top