Is there such as thing? I have loaded a layout when my app runs and then when the user clicks a menu item I load another layout. The problem is it's appearing over the top of the first one so you can see both. Is it possible to close a layout?
I've tried Activity.Finish but that closes the whole app!
B4X:
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("PowerZones")
Activity.AddMenuItem("Power Zones", "PowerZones")
Activity.AddMenuItem("Heart Zones", "HeartZones")
End Sub
Sub PowerZones_Click
'This is where I would like to close any other layout that is loaded
Activity.LoadLayout("PowerZones")
End Sub
Sub HeartZones_Click
'This is where I would like to close any other layout that is loaded
Activity.LoadLayout("HeartZones")
End Sub
Your problem that is see both of scenes,correct?
I have experience,I created panel before for contains many objects in each scenes. And use command layout1.visiable=false : layout2.visiable=true
Best regards
Theera
With this code, what if you loaded a layout file but you also created some views in code that are not part of the layout and wish to keep them. Can this code be made to remove just the views that the layout loaded? Or would it be better to just load the view in a panel and when ready, remove the panel view?
Both are possible, with the panel it's somewhat easier.
But if you save the number of views on the activity just after having loaded the layout in LayoutViewNb and then add other views by code. You can remove the layout views afterwads with:
B4X:
For i = 0 To LayoutViewNb - 1
Activity.RemoveViewAt(0)
Next
When I create a layout I use a panel full screen as a container and place all views I need inside of the panel. When I want the layout to go away I say panel.removeView for the containing panel. This removes all views in the layout.