Activity.CloseLayout?

School Boy Error

Member
Licensed User
Longtime User
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!

Code: Copy
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
 
There is no LayoutClose function.
What you can do is:
Code: Copy
Sub RemoveAllViews
    Dim i As Int
    
    For Activity.NumberOfViews - 1 To 0 Step -1
        Activity.RemoveViewAt(i)
    Next
End Sub
Or add a Panel for the second layout and set the Panel.Visible property to False or True.
Or use a new Activity.

Best regards.
 
Upvote 0
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
 
Upvote 0
There is no LayoutClose function.
What you can do is:
Code: Copy
Sub RemoveAllViews
    Dim i As Int
    
    For Activity.NumberOfViews - 1 To 0 Step -1
        Activity.RemoveViewAt(i)
    Next
End Sub
Or add a Panel for the second layout and set the Panel.Visible property to False or True.
Or use a new Activity.

Best regards.

Klaus, I've tried this but it says

Code: Copy
Compiling code.                         Error
Error compiling program.
Error description: Regular variable followed by '=' expected.
Occurred on line: 119
For Activity.NumberOfViews - 1 To 0 Step -1        
Word: .
 
Upvote 0
Upvote 0
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?

Thanks,

Margret
 
Upvote 0
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:
Code: Copy
For i = 0 To LayoutViewNb - 1
  Activity.RemoveViewAt(0)
Next
Best regards.
 
Upvote 0
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.
 
Upvote 0
Back
Top