Android Question xcustomlistview and csbuilder

Addo

Well-Known Member
Licensed User
there is word wrap issue when using xcustomlistview with csbuilder if the text is too long and image is inserted with csbuilder the item height does not change based on the text size the text goes inside the item and become not visible i am using the following code by Erel


B4X:
Sub Process_Globals
   Private smileyBmp As Bitmap
End Sub

Sub Globals
   Private Label1 As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
   If FirstTime Then
       smileyBmp = LoadBitmap(File.DirAssets, "smiley.png")
   End If
   Activity.LoadLayout("1")
   Label1.Text = ReplaceSmilies("hi :) this is text message with smiley sample ;) on how to use csbuilder to replace smiley chars with images :-) and so on")
  
End Sub

Sub ReplaceSmilies(s As String) As CSBuilder
   Dim rb As RegexBuilder
   rb.Initialize
   For Each smiley As String In Array(":)", ";)", ":-)")
       If rb.Pattern <> "" Then rb.AppendOr
       rb.StartNonCapture.AppendEscaped(smiley).EndNonCapture
   Next
   Return MarkPattern(s, rb.Pattern, 0)
End Sub

Sub MarkPattern(Input As String, Pattern As String, GroupNumber As Int) As CSBuilder
   Dim cs As CSBuilder
   cs.Initialize
   Dim lastMatchEnd As Int = 0
   Dim m As Matcher = Regex.Matcher(Pattern, Input)
   Do While m.Find
       Dim currentStart As Int = m.GetStart(GroupNumber)
       cs.Append(Input.SubString2(lastMatchEnd, currentStart))
       lastMatchEnd = m.GetEnd(GroupNumber)
       'apply styling here
       Log(m.Group(GroupNumber))
       cs.Image(smileyBmp, 30dip, 30dip, True)
   Loop
   If lastMatchEnd < Input.Length Then cs.Append(Input.SubString(lastMatchEnd))
   Return cs
End Sub
 

Addo

Well-Known Member
Licensed User
i thought its csbuilder certain here is the clv code
B4X:
Sub CreateListItem(Text As String, Width As Int, Height As Int) As Panel
   
   Dim p As Panel
   p.Initialize("")
   p.SetLayout(0, 0, Width, Height)
   p.LoadLayout("chatlay")
   Label1.Text = ReplaceSmilies(Text)
   Label1.TextColor = 0xff000000
   Return p
End Sub


Sub Button1_Click
    
CustomListView1.Add(CreateListItem(EditText1.Text, CustomListView1.AsView.Width, 50dip), EditText1.Text)
    
End Sub
 
Upvote 0
Top