Android Question CustomListView Monospace Font Not Working

mmieher

Active Member
Licensed User
Longtime User
In the designer, I set the Typeface for a CLV as MONOSPACE, but it is not presenting a monospace font.

Any ideas?
 

DonManfred

Expert
Licensed User
Longtime User
You set a font for the CLV itself. Probably NOT for the children
Check the objects you add to this CLV. They must have a Font set if you want to have specific fonts.
I mean: Label, Edittext, whatever...
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
just clv1.AddTextItem
Have a look at this method in the class.
You ARE adding objects to the CLV. In this case a Label

change the class methods similar to this...

B4X:
'Adds a text item. The item height will be adjusted based on the text.
Public Sub AddTextItem(Text As String, Value As Object)
    InsertAtTextItem(items.Size, Text, Value)
End Sub

'Inserts a text item at the specified index.
Public Sub InsertAtTextItem(Index As Int, Text As String, Value As Object)
    Dim pnl As Panel
    pnl.Initialize("")
    Dim lbl As Label
    lbl.Initialize("")
    pnl.AddView(lbl, 5dip, 2dip, sv.Width - 5dip, 20dip)
    Dim font As Typeface
    lbl.Typeface = font.MONOSPACE
    lbl.Text = Text
    If DefaultTextBackground <> Null Then
        pnl.Background = DefaultTextBackground
    Else
        pnl.Color = DefaultTextBackgroundColor
    End If
    Dim minHeight As Int
    minHeight = su.MeasureMultilineTextHeight(lbl, Text)
    lbl.Height = Max(50dip, minHeight)
    InsertAt(Index, pnl, lbl.Height + 2dip, Value)
End Sub
 
Upvote 0
Top