Android Question [solved] Widget - wrong char when using Materialicons

udg

Expert
Licensed User
Longtime User
Hi all, experimenting with a widget creation, I tried to use the Materialicons font in order to show a "refresh" icon on a label (instead of using an image).
Properly setting (in Designer) Typeface and selecting the right icon in the correct icon group (0xE5D5), it results in an empty label on my widget.
Another attempt from code:
B4X:
Dim cs As CSBuilder
cs.Initialize.Typeface(Typeface.MATERIALICONS).Append(Chr(0xE5D5)).Pop.PopAll
rv.SetText("lblUpdt", cs)
The code above shows a chinese-like character.
My manifest is really basic:
B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="28"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
'End of default text.

'needed because APIs use http instead of https
CreateResourceFromFile(Macro, Core.NetworkClearText)
From an older thread it seems that the problem could be a setting on the phone, related to Themes. On a Galaxy 40 (Android 10) I wasn't able to find anything useful. Same for an Huawei Y550-L01 (android 4.4.4).

Any idea?
Thank you.
 
Last edited:

udg

Expert
Licensed User
Longtime User
Hi,
I solved it making use of a UTF code (0x27F2).
I tried using its decimal equivalent (10226) in the Designer but failed. So, as a second attempt, I modified the code with CsBuilder above as such:
B4X:
Dim cs As CSBuilder
cs.Initialize.Typeface(Typeface.MONOSPACE).Append(Chr(0x27F2)).Pop.PopAll
rv.SetText("lblUpdt", cs)
and that worked!

Reason for this new attempt is that, altough the home screen app didn't allow fonts like Materialicons or Fontawesome, it could have possibly worked with UTF. So, I tried and succeded.
Can you anticipate any problem? BTW, in this case the widget would be for my own use only ..and since it works on my phones..eheh)

Thank you.
 
Last edited:
Upvote 0
Top