Android Question SetTitle in B4XPages with CSBuilder and clickable word

Andie

Member
Licensed User
Longtime User
In B4xPages I can create a title like this
B4X:
Dim cs As CSBuilder
cs =  .... something wird createclickableword()
...
...
B4XPages.SetTitle(Me, cs)
cs.EnableClickEvents(Root)
However, the last line causes an error, the same with "Me" as parameter instead of "Root"
Is it possible to make a word in the title clickable?
Furthermore, can I make an icon (e. g. FONTAWESOME element) clickable? And if yes, does it work in the title?

Thanks!
 

Mahares

Expert
Licensed User
Longtime User
Is it possible to make a word in the title clickable?
Yes. Create a custom actionbar like this:.
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0, 300dip, 60dip)
    p.LoadLayout("actionbar")    'Layout has label1 only
    p.SetColorAndBorder(xui.Color_Cyan, 4dip, xui.Color_White, 3dip)
    B4XPages.GetManager.ActionBar.RunMethod("setCustomView", Array(p))
    B4XPages.GetManager.ActionBar.RunMethod("setDisplayOptions", Array(16, 16))
    Dim cs As CSBuilder
    cs.Initialize.Append(CreateClickableWord("Google")).PopAll
    Label1.Text =cs
    cs.EnableClickEvents(Label1)
    B4XPages.SetTitle(Me, "")

    Root = Root1
    Root.LoadLayout("1")
'rest of your other code
B4X:
Sub CreateClickableWord(Text As String) As CSBuilder
    Dim cs As CSBuilder
    Return cs.Initialize.Underline.color(xui.Color_Blue).Clickable("Word", Text).Append(Text).PopAll
End Sub
B4X:
Sub Word_Click (Tag As Object)
    Log($"You have clicked on word: ${Tag}"$)
'    rest of your code
End Sub

For fontawesome the same way and it works:
B4X:
cs.Initialize.append("    ").bold.Typeface(Typeface.FONTAWESOME).Append(CreateClickableWord(Chr(0xF0A4))).PopAll
 
Last edited:
Upvote 0
Top