Android Question TypeFace and ListView

MarcoRome

Expert
Licensed User
Longtime User
Hi all, i have this problem, when i change listview with characters different i have this effect:

2aha5bq.png


The original Code is this:
B4X:
                For i = 0 To COUNTRIES.Size - 1
                    m = COUNTRIES.Get(i)
                    'Setto Carattere
                    TimeFont =  Typeface.LoadFromAssets("jurassic.ttf")
                    ListView1.TwoLinesAndBitmap.Label.Typeface = TimeFont
                    ListView1.TwoLinesAndBitmap.Label.TextColor = Colors.Black
                    ListView1.TwoLinesAndBitmap.Label.TextSize = 18dip
                  
                    ListView1.TwoLinesAndBitmap.SecondLabel.TextColor = Colors.Black
                    ListView1.TwoLinesAndBitmap.SecondLabel.Typeface = Typeface.DEFAULT
                    ListView1.FastScrollEnabled = True
                    'ListView1.ScrollingBackgroundColor = Colors.black
                    'ListView1.Color = Colors.Black
                    ListView1.AddTwoLinesAndBitmap2(m.Get("genere"),"Totale: " & m.Get("totale") , LoadBitmap(File.DirAssets, m.Get("icona_barzelletta") ),  m.Get("genere")  )
                Next

the first row as you see have different TTF another row (2,3, etc ) work ( as you see into picture ).


Second.. when i click top listview i have this code, and if you see i change TypeFace in stars.ttf:

B4X:
                For i = 0 To COUNTRIES.Size - 1
                    m = COUNTRIES.Get(i)
                    'Setto Carattere
                    ListView1.TwoLinesAndBitmap.Label.Typeface = Typeface.DEFAULT
                    ListView1.TwoLinesAndBitmap.Label.TextColor = Colors.Black
                    ListView1.TwoLinesAndBitmap.Label.TextSize = 8dip
                    ListView1.TwoLinesAndBitmap.Label.Gravity = Gravity.TOP
                  
                    TimeFont1 =  Typeface.LoadFromAssets("stars.ttf")
                    ListView1.TwoLinesAndBitmap.SecondLabel.Typeface = TimeFont1
                    ListView1.TwoLinesAndBitmap.SecondLabel.TextColor = Colors.Red
                    ListView1.FastScrollEnabled = True

                    ListView1.AddTwoLinesAndBitmap2(m.Get("barzelletta"), m.Get("voto"), LoadBitmap(File.DirAssets, m.Get("icona_barzelletta") ),  m.Get("id")  )
Next

But ths result is this:

11ce8uf.png


also here the first row as you see have different TTF another row (2,3, etc ) work ( as you see into picture ).

Any idea ??
Thank you
Marco
 

Peter Simpson

Expert
Licensed User
Longtime User
Hello,
What happens if you set the Typeface right after initializing the ListView1 and before you start the For Loop?

Basically try taking the Typeface out of the For Loop.
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
Hello,
What happens if you set the Typeface right after initializing the ListView1 and before you start the For Loop?

Basically try taking the Typeface out of the For Loop.

Hi Peter, yes i try in different mode:

B4X:
Sub Globals
   
       'These global variables will be redeclared each time the activity is created.
       'These variables can only be accessed from this module.
               
......
    Dim TimeFont, TimeFont1 As Typeface
    TimeFont =  Typeface.LoadFromAssets("jurassic.ttf")
    TimeFont1 =  Typeface.LoadFromAssets("stars.ttf")
End Sub
 
 
 
'Setto Carattere
ListView1.TwoLinesAndBitmap.Label.Typeface = TimeFont
ListView1.TwoLinesAndBitmap.Label.TextColor = Colors.Black
ListView1.TwoLinesAndBitmap.Label.TextSize = 18dip
ListView1.TwoLinesAndBitmap.SecondLabel.TextColor = Colors.Black
ListView1.TwoLinesAndBitmap.SecondLabel.Typeface = Typeface.DEFAULT
 
For i = 0 To COUNTRIES.Size - 1
m = COUNTRIES.Get(i)
ListView1.FastScrollEnabled = True
ListView1.AddTwoLinesAndBitmap2(m.Get("genere"),"Totale: " & m.Get("totale") , LoadBitmap(File.DirAssets, m.Get("icona_barzelletta") ), m.Get("genere") )
Next

but anyway same result.
I solved using two Listview
Thank you anyway
Marco
 
Upvote 0
Top