private Sub setupcontents
clv.Add(CreateAnEntry(clv.AsView.Width,"top","This is some text that should wrap in because it is longer than the width of the panel. Note it does not have any CR's in it","bot"),0)
clv.Add(CreateAnEntry(clv.AsView.Width,"This is some text that should wrap in because it is longer than the width of the panel. Note it does not have any CR's in it","mid","bot"),0)
clv.Add(CreateAnEntry(clv.AsView.Width,"top","mid","This is some text that should wrap in because it is longer than the width of the panel. Note it does not have any CR's in it"),0)
End Sub
private Sub CreateAnEntry(w As Int, t1 As String,t2 As String,t3 As String) As B4XView
Dim p As B4XView = xui.CreatePanel("")
Dim s As String = t1 & CRLF & t2 & CRLF & t3
Dim fnt As B4XFont = xui.CreateDefaultFont(15)
Dim height As Int = MeasureMultilineTextHeight(fnt, w - 10dip, s)
p.SetLayoutAnimated(0, 0, 0, w, height + 10dip)
Dim lbl As B4XView = XUIViewsUtils.CreateLabel
lbl.As(Label).WrapText = True
lbl.Font = fnt
lbl.Text = s
lbl.TextColor = xui.Color_Black
p.AddView(lbl, 5dip, 5dip, w - 10dip, height)
Return p
End Sub
#if b4j
Private Sub MeasureMultilineTextHeight (Font As Font, Width As Double, Text As String) As Double
Dim jo As JavaObject = Me
Return jo.RunMethod("MeasureMultilineTextHeight", Array(Font, Text, Width))
End Sub
#if Java
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import javafx.scene.text.Font;
import javafx.scene.text.TextBoundsType;
public double MeasureMultilineTextHeight(Font f, String text, double width) throws Exception {
Method m = Class.forName("com.sun.javafx.scene.control.skin.Utils").getDeclaredMethod("computeTextHeight",
Font.class, String.class, double.class, TextBoundsType.class);
m.setAccessible(true);
return (Double)m.invoke(null, f, text, width, TextBoundsType.LOGICAL_VERTICAL_CENTER);
}
#End If
#End If
#End Region