I use a text file named MaterialIcons-WebFont.txt obtained from one of Erels’ threads to retrieve the names of the material icons and use the below csbuilder code to display on a B4XListTemplate. But, I am not able to display the material icons corresponding to each text file name. How should I modify the below code to also see the icons by incorporating a font file called: materialdesignicons-webfont.ttf (from one of Erels’ threads).
B4X:
For Each line As String In File.ReadList(File.DirAssets, "MaterialIcons-WebFont.txt")
Dim cs As CSBuilder
B4XListTemplate1.Options.Add(cs.Initialize.Color(xui.Color_White).Size(20). _
Append(line.SubString(1)).append(TAB).Pop.Typeface(Typeface.MATERIALICONS).Append(line.CharAt(0)).PopAll)
Next
If I use the line below, how do I include it in the csbuilder construct:
Dim fnt As B4XFont = xui.CreateFont(Typeface.LoadFromAssets("materialdesignicons-webfont.ttf"),50)
Thank you
Dim fnt As Typeface = Typeface.LoadFromAssets("materialdesignicons-webfont.ttf")
For Each line As String In File.ReadList(File.DirAssets, "MaterialIcons-WebFont.txt")
Dim cs As CSBuilder
B4XListTemplate1.Options.Add(cs.Initialize.Color(xui.Color_White).Size(20). _
Append(line.SubString(1)).append(TAB).Pop.Typeface(fnt).Append(line.CharAt(0)).PopAll)
Next
the above suggested code works great. I like to display the image part of the icon(font) onto a label. I use the below code. It displays it, but the icon is really tiny in the middle of the label. Not sure if this is the best way to do it.
B4X:
If Result = xui.DialogResponse_Positive Then
MySelection = B4XListTemplate1.SelectedItem
Dim s() As Object=Regex.Split(TAB,MySelection)
Dim lbl As Label
lbl.Initialize("")
lbl.Typeface = fnt
lbl.Text=s(1)
lbl.Color=Colors.green
lbl.TextColor=Colors.black
lbl.Gravity=Gravity.CENTER_vertical+Gravity.CENTER_HORIZONTAL
Activity.AddView(lbl, 0, 0, 100dip, 100dip)