StringUtils error

JonPM

Well-Known Member
Licensed User
Longtime User
I am receiving this error message:
"java.lang.IllegalArgumentException: Layout: -1 < 0" on this line:
lblClass.Height = SU.MeasureMultilineTextHeight(lblClass, lblClass.Text)

Erel pointed out the problem in this post

However, my issue is that I am using:
scvMain.Panel.LoadLayout("MyLayout")

MyLayout contains all of the labels (including lblClass). I am assuming the error is being thrown because the inner panel width is set to -1. I have tried changing it with:
scvMain.Panel.Width = 100%x
But that doesn't work. I was hoping to continue using the layout file to reduce the amount of code needed. Is there any other way?
 
Sorry, forgot to mention that the scrollview is added programmically, then the layout is loaded. I have tried changing the values above 0 but I still get the same error message.

Here's the scrollview code:
Code:
scvMain.Initialize(100%y)
Activity.AddView(scvMain, 0, 0, 100%x, 100%y)
scvMain.Panel.LoadLayout("MyLayout")
scvMain.Panel.Width = scvMain.Width
scvMain.Panel.Height = scvMain.Height
 
Last edited:
Upvote 0
What is the line of code under debug that throws the error? Is it:

Code:
lblClass.Height = SU.MeasureMultilineTextHeight(lblClass, lblClass.Text)

If so, what does the log value of each show for:

lblClass
lblClass.Text
SU.MeasureMultilineTextHeight(lblClass, lblClass.Text)

Also, what is: scvMain.Initialize(100%y)
What is scvMain dimmed as, what type?
 
Last edited:
Upvote 0
Yes, the error is on that line of code.

scvMain is the Scrollview.

Log(SU.MeasureMultilineTextHeight(lblClass, lblClass.Text)) shows:
(TextView): Left=20, Top=220, Width=-1, Height=100, Tag=, Text=Hello World
 
Upvote 0
Thanks for your help margret, I was able to find the solution. I have to use this code right before the SU line:
lblClass.Width = scvMain.Width

It was getting the -1 from the lblClass.Width = 100%x line...
 
Upvote 0
Great! Glad you found it. I was just about to post this test code that was working for me.

Code:
Sub Globals
   Dim lblClass As Label
    lblClass.Initialize("")
   lblClass.Text = "this is a long sentence"
   Activity.AddView(lblClass, 10dip, 10dip, 200dip, 30dip)
   lblClass.TextSize = 20
   Dim su As StringUtils
   lblClass.Height = su.MeasureMultilineTextHeight(lblClass, lblClass.Text) 
   Msgbox(su.MeasureMultilineTextHeight(lblClass, lblClass.Text))
End Sub
 
Upvote 0
Back
Top