Spinner font typeface

pwme

Member
Licensed User
Longtime User
Hi,

how to change spinner font typeface?

Spinner_font=Typeface.SERIF
Spinner_font=Typeface.CreateNew(Spinner_font, Spinner_font.STYLE_BOLD)

and then how to assign it to a spinner

Dim S As Spinner
S.Initialize("spinner")
S.?

Many thanks in advance

William
 

pwme

Member
Licensed User
Longtime User
Hi Erel,

Nothing is impossible for me! I'm kidding of course! I finded out a solution.

Dim Spinner_List_Value() As List
Dim Spinner_ListID As Int

For i = 0 To cursor1.RowCount - 1
cursor1.Position = i
' Set ID
Spinner_List_ID(0).add(cursor1.GetString2(0))
' Set String to view
Dim rs As RichString
rs.Initialize(cursor1.GetString2(1))
rs.Style(Typeface.STYLE_ITALIC,0, rs.Length)
Spinner_List_value(0).Add(rs)
Next

and then...

Dim S As Spinner
S.Initialize("spinner")
MyEditView.Panel.AddView(......)
S.AddAll(Spinner_List_Value(Spinner_ListID))

Best regards

William
 
Upvote 0

DrownedBat

Member
Licensed User
Longtime User
What would this look like if you were using mapping instead of SQL? I can't seem to adapt it properly:

Dim mapNation as Map
Dim strNation as String
Dim SpinnerListID() as Int
Dim SpinnerList() as List

'Nationality List
mapNation.Initialize
For i = 0 To 1
If i=0 Then strNation="United States of America"
If i=1 Then strNation="Great Britain"
'etc...
mapNation.Put(i, strNation)
Next

For i = 0 To mapNation.Size -1
'Set ID
SpinnerListID(i)=mapNation.GetKeyAt(i)
'Set string to view
Dim rs As RichString
rs.Initialize(mapNation.GetValueAt(i))
rs.Style(Typeface.STYLE_BOLD, 0, rs.Length)
SpinnerList(i).Add(rs)
Next
 
Upvote 0

DrownedBat

Member
Licensed User
Longtime User
I was wondering how to do that...

Alright, I've plugged this into the code and it still crashes. Perhaps it's because I'm trying to load a custom font into it?
B4X:
For Each s As String In mapNation.Values
        Dim rs As RichString
        rs.Initialize(s)
        rs.Style(Typeface.LoadFromAssets("armalite.ttf"), 0, rs.Length)
        spnNation.AddAll(Array As Object(rs))
    Next
 
Upvote 0

artsoft

Active Member
Licensed User
Longtime User
RichString doesn't support custom fonts.

Thats not completely correct ........ In the code of DrownedBat I can see that he used the Style command - for setting the style - but with a TTF font (?)

He should use the Typeface command or better for custom fonts the TypefaceCustom command, i. e. :

B4X:
For Each s As String In qualList.Values
    Private rs As RichString
    rs.Initialize(s)
    rs.BackColor(Colors.RGB(0, 100,255), 0, rs.Length)
    rs.Color(Colors.White, 0, rs.Length)
    rs.RelativeSize(tSize/14, 0, rs.Length)
    rs.ScaleX(1, 0, rs.Length)
    rs.Style(Typeface.STYLE_NORMAL, 0, rs.Length)
    rs.TypefaceCustom(Typeface.LoadFromAssets("gothic.ttf"), 0, rs.Length)
    spinner.AddAll(Array As Object(rs))
Next

****************************************************************************
U P D A T E:

Ok, I see now that Erel made some updates to this RS lib, which allows
now to handle custom fonts :) !

Please follow this link of Erel:
https://www.b4x.com/android/forum/threads/richstring-library.10680/page-6#post-475477

GREAT!!!!
****************************************************************************

Regards
ARTsoft
 
Last edited:
Upvote 0
Top