Android Question Scroll View -- My label to add is null?

Torby

Member
Licensed User
Longtime User
This is my first post here. Do you have code tags?

Trying to make a scrollview's items vary in height according to the text size., so inside my loop, I have:

B4X:
TopOfLine = y
Dim l As Label
l.Initialize("")
l.Gravity = Gravity.Left
l.TextSize = 32
l.TextColor = Colors.White
A = s.IndexOf2("|",0)
A = s.IndexOf2("|",A+1)
B = s.IndexOf2("|",A+1)
n = i+1
l.Width = w  ' *********** blows up here! ***********************
l.Text = n & ". " & s.SubString2(A+1,B)
l.Height = su.MeasureMultilineTextHeight(l, l.Text)
svOrder.Panel.Height = svOrder.Panel.Height + l.Height
LabelList.Add(l)
svOrder.Panel.AddView(l,5,y,svOrder.Width-5,l.Height)
y = y + l.Height

And above,
B4X:
Dim w As Int = svList.Width
Dim y As Int = 0
However, it blows up when I try to set l.Width claiming a null pointer reference. It's already set l.TextSize and l.TextColor and l.Gravity.

Perhaps I should use another label for sizing the text, and not the one I just dimmed?

Dimly yours,
Toby

p.s. Oh, you do have code tags. And they are most beautiful.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…