Hey All, so I'm using the ACToolbarLight, but when I switch from the main layout to another layout and back, the menu items duplicate, so if I have 4 menu items before, and switch back I now have 8, switch again and I have 12. I have combed through this with a fine tooth comb and no luck. Funny enough, I have used the same menu on my previous app and that hasnt happened. I change my code to match the tutorials and its still happening. Can you guys see where the error is please?
B4X:
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
Activity.LoadLayout("Splash")
lblTitle.Text = "App Name"
SplashTimer.Initialize("SplashTimer", 3000)
SplashTimer.Enabled = True
Else
If File.Exists (File.DirInternal, "MSState.txt") = False Then
LoadMain
Else
strState = File.ReadString(File.DirInternal, "MSState.txt")
RemoveView
Activity.LoadLayout("AlarmLayout")
End If
File.Delete(File.DirInternal,"MSState.txt")
End If
End Sub
Sub LoadMain
RemoveView
Activity.LoadLayout("MainLayout")
LoadMenu
If File.exists(File.DirInternal, "Tutorial.txt") = False Then
RemoveView
Activity.LoadLayout("tutorial")
File.WriteString(File.DirInternal, "Tutorial.txt", "Tutorial Complete")
End If
End Sub
Sub LoadMenu
Dim bd As BitmapDrawable
bd.Initialize(LoadBitmap(File.DirAssets,"logo_small.png"))
ToolBar.NavigationIconDrawable = bd
ToolbarHelper.Initialize
ToolbarHelper.ShowUpIndicator = False 'set to true to show the up arrow
ToolBar.InitMenuListener
Activity.AddMenuItem("User Options", "User")
Activity.AddMenuItem("Settings", "Settings")
Activity.AddMenuItem("Test Alarm", "TestAlarm")
End Sub
Sub TestAlarm_Click
RemoveView
Activity.LoadLayout("AlarmDetected")
End Sub
Sub btnAlarmClose_Click
RemoveView
LoadMain
End Sub
Sub btnTutorialClose_Click
RemoveView
LoadMain
End Sub
Sub btnSettingsClose_Click
RemoveView
LoadMain
End Sub
Sub RemoveView
Dim i As Int
For i=Activity.NumberOfViews-1 To 0 Step -1
Activity.RemoveViewAt(i)
Next
End Sub