Trying to use StringUtils to measure text height and adjust height of a label as required. I get an error on the red Line. Can anybody see why? My code that is concerned with this function appears to match the example in the tool tip. The error shown is below.
lblDetail.Height = su.MeasureMultilineTextHeight(lblDetail, lblDetail.Text)
Any info welcomed
Thanks
lblDetail.Height = su.MeasureMultilineTextHeight(lblDetail, lblDetail.Text)
B4X:
Sub AddCheckBoxItem(Title As String, CheckedDetail As String, UncheckedDetail As String, Checked As Boolean)
Dim P As Panel
Dim lblTitle, lblDetail As Label
Dim chkBox As CheckBox
Dim su As StringUtils
P.Initialize("Preference")
svPreferences.Panel.AddView(P, 0, svPosition, (svPreferences.Panel.Width - 48dip), ItemHeight)
P.Tag = Title
lblTitle.Initialize("")
lblTitle.Text = Title
P.AddView(lblTitle, 10dip, 10dip, (svPreferences.Panel.Width - 48dip), 30dip)
lblTitle.Tag = "Title"
lblDetail.Initialize("")
If Checked = True Then
lblDetail.Text = CheckedDetail
Else
lblDetail.Text = UncheckedDetail
End If
P.AddView(lblDetail, 10dip, 40dip, svPreferences.Panel.Width, 30dip)
lblDetail.Height = su.MeasureMultilineTextHeight(lblDetail, lblDetail.Text)
lblDetail.Tag = "Detail"
chkBox.Initialize("ChkBox")
P.AddView(chkBox, P.Width - 20dip - 48dip, lblTitle.Top, 48dip, 48dip)
chkBox.Tag = "Check"
If (lblTitle.Height + lblDetail.Height + 4dip) > ItemHeight Then
P.Height = lblTitle.Height + lblDetail + 4dip
End If
End Sub
B4X:
java.lang.IllegalArgumentException: Layout: -1 < 0
Any info welcomed
Thanks