Android Question DSTabLayout with Fontawesome?

leitor79

Active Member
Licensed User
Longtime User
Hi,

I have a DSTabLayout and I wanted to use the fontawesome font to add some kind of icons. Icons are not displayed, just the text.

(Dim VP As AHViewPager, Dim PC As AHPageContainer)

B4X:
    PC.Initialize
       
    Panel1.Initialize("")
    Panel1.Color = Colors.White 'Colors.RGB(Rnd(0,256), Rnd(0,256), Rnd(0,256))
    'PC.AddPage(Panel1, Chr(0xF080))
    PC.AddPage(Panel1, Chr(0xF080) & " Chart")
    Panel2.Initialize("")
    Panel2.Color = Colors.White 'Colors.RGB(Rnd(0,256), Rnd(0,256), Rnd(0,256))
   
    PC.AddPage(Panel2, Chr(0xF0F6)  & " Raw Data")

   
    'Set the PageContainer for the ViewPager
    VP.PageContainer = PC
    TabLayout.SetViewPager(VP)

TabLayout and VP has set typeface=fontawesome in the designer. I also added an invisible lblFontAwesome label, with fontawesome typeface, just in case (i think it was necessary in older versions?)

I know dstablaoyut supports the seticon method, but I thought using the font is easier.

Thank yoy very much!
 

DonManfred

Expert
Licensed User
Longtime User
Have you tried to use the CharSequenceBuilder?
 
Upvote 0

leitor79

Active Member
Licensed User
Longtime User
Hi DonManfred, thank you for your answer!

I didn't knew such thing existed. I've read some topic with a question answered using something with cs and I tought it had something to do with c# haha.

However, I've looked for it, and I tried, but it doesn't work:

B4X:
PC.AddPage(Panel1,  cs.Initialize.Append("Text with FontAwesome: ").Typeface(Typeface.FONTAWESOME).Append(Chr(0xF209)).PopAll)

Thank you very much!
 
Upvote 0

leitor79

Active Member
Licensed User
Longtime User
Hi,

I also tried with SetTabText, that says it accept a charsequence, but it only displays the text with no icons:

B4X:
    TabLayout.SetTabText(0, cs.Initialize.Append("FontAwesome: ").Typeface(Typeface.FONTAWESOME).Append(Chr(0xF209)).PopAll)
   
    TabLayout.SetTabText(1, cs.Initialize.Typeface(Typeface.FONTAWESOME).Append(Chr(0xF060)).Append(" Raw Data").PopAll)
 
Upvote 0

leitor79

Active Member
Licensed User
Longtime User
Thank for your answer, DonManfred.

AppCompat v3.52, as says in the libraries panel, and AHViewPager v3.00
 
Upvote 0

leitor79

Active Member
Licensed User
Longtime User
Hello,

Maybe my answer implied there was something wrong with the appcompat or DSL versions, but I really don't know it there was the case...


Regards!
 
Upvote 0
Top