Android Question B4XPages subtitle in the actionbar

Erel

B4X founder
Staff member
Licensed User
Longtime User
1624943213825.png


B4X:
Sub SetSubtitle(Text As Object)
    #if B4A
    Dim actionbar As JavaObject = B4XPages.GetManager.ActionBar
    If actionbar.IsInitialized Then
        actionbar.RunMethod("setSubtitle", Array(Text))
    End If
    #End If
End Sub

You can pass a String or CSBuilder.

Note that the subtitle will appear in all pages. If you want to change the subtitle in each page then do it in the B4XPage_Appear event.
 
Upvote 0
View attachment 115608

B4X:
Sub SetSubtitle(Text As Object)
    #if B4A
    Dim actionbar As JavaObject = B4XPages.GetManager.ActionBar
    If actionbar.IsInitialized Then
        actionbar.RunMethod("setSubtitle", Array(Text))
    End If
    #End If
End Sub

You can pass a String or CSBuilder.

Note that the subtitle will appear in all pages. If you want to change the subtitle in each page then do it in the B4XPage_Appear event.
Thanks Erel for the help.
I researched and I didn't find it, it is possible to disable the Subtitle because I only need to use it in two pages of the project.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I didn't find it, it is possible to disable the Subtitle because I only need to use it in two pages of the project.
This is how I did it:
In B4XMainPage:
B4X:
Public Sub SetSubtitle(Text As Object)
    #if B4A
    Dim actionbar As JavaObject = B4XPages.GetManager.ActionBar
    If actionbar.IsInitialized Then
        actionbar.RunMethod("setSubtitle", Array(Text))
    End If
    #End If
End Sub

B4X:
Sub b4xPage_Appear
    Dim cs As CSBuilder
    cs.Initialize.Color(xui.Color_Red).Append("World ").Pop.Color(xui.Color_Blue).Append("Flags").PopAll
    SetSubtitle(cs)  'subtitle can be text also
End Sub

In the page where I do not want it to appear I did this:
B4X:
Sub b4xPage_Appear
     B4XPages.MainPage.SetSubtitle("")
'    your other code
End Sub

In the page where I want to change it I did this:
B4X:
Sub b4xPage_Appear
     B4XPages.MainPage.SetSubtitle("Statistics")
'    your other code
End Sub
 
Upvote 0
Top