Android Question Question on StdActionBar Tabs tabChanged event


Licensed User
Longtime User
In my MAIN activity, I have a reference to the StdActionBar library with the following code:

Sub Activity_Create(FirstTime As Boolean)

bar.NavigationMode  =  bar.NAVIGATION_MODE_TABS

bar.Subtitle = "EAM 3663 Main Menu"
bar.ShowUpIndicator = False
bar.Icon = LoadBitmap(File.DirAssets, "actionbarlogo.png")

bar.AddTab("Main Menu").Tag = "tabMainMenu"
bar.AddTab("Chkr Acctg").Tag = "tabChkrAcctg"
bar.AddTab("Office Acctg").Tag = "tabOfficeAcctg"

End Sub

Sub bar_TabChanged(Index As Int, sTab As StdTab)
    If Index = 0 Then
    End If
End Sub

When the activity fires up for the first time, the bar_TabChanged event is fired and the "aChkrAcctg" activity is started without the user touching the tab.

When the Activity_Create is executed and the tabs are built, is there a way to not have the bar_TabChanged event fire until the user actually touches the tab?

Thank you.


B4X founder
Staff member
Licensed User
Longtime User
I think that it will be better that the first tab will not be the tab that switches activities.
Otherwise the user will see a page and then when she tries to return to that page a new activity will start from nowhere.

You can add a global flag variable. Set it to true in Activity_Create.
Sub bar_TabChanged(Index As Int, STab As StdTab)
   If disableJump Then
     disableJump = False
   End If
End Sub
Upvote 0