Android Question Troubles with MeasureMultilineTextHeight, richstring and customListview

Sub7

Active Member
Licensed User
Longtime User
Hello!
I need some help because i am getting crazy to make this thing works, i need to set the height of the label according to the length of text here a pseudocode which does not works at all, label height is not set.

B4X:
Sub Activity_Create(FirstTime As Boolean)

   Activity.LoadLayout("chatlayout2")
   ' This layout has an edittext and a button


End sub

Sub fill_clv

    Dim parser As JSONParser
    parser.Initialize(fetchItems) ' = job.getstring
    Dim ITEMS As List
        ITEMS = parser.NextArray
        For i = 0 To ITEMS.Size - 1      
        Dim m As Map
        m = ITEMS.get(i)
        id = m.Get("id")
        subject= m.get("subject")
        message = m.get("message")
        color= m.get("color")  
   
                'Richstring
                messageContent.Initialize("{Grey}" &subject&":"" {Grey}"&"{color}"&message&"{color}" )  
                Dim values() As String
                values = Regex.Split(",", chatcolor)
                messageContent.Color2(Colors.rgb(228,228,228),"{Grey}")
                messageContent.Color2(Colors.RGB(values(0),values(1),values(2)), "{color}")
                  
                    Dim p As Panel
                    p.Initialize("")
                    p.Color = Colors.RGB(0,0,0)
                    label1.Text = messageContent
                    label1.Color = Colors.RGB(0,0,0)
                    Dim su As StringUtils
                    label1.Height = su.MeasureMultilineTextHeight(label1, label1.Text.Length)  
                    chatlistview.Add(p, label1.Height, subject)
  
                    p.LoadLayout("labellayout")
                    'This layout has only a label 
                     Log(lblchatmessage.Height)
    Next
          
End sub

Thank you
 
Top