iOS Question Layouts + Exit

carchek

Member
Licensed User
Longtime User
Hi!
I have a layout1 and I call it in application start sub, than I also have some buttons. How to call other layout to show and hide layout1 and show layout2?
B4X:
rivate Sub Application_Start (Nav As NavigationController)
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.Title = "XĐ"
    Page1.RootPanel.LoadLayout("Start")
    Page1.RootPanel.Color = Colors.White
    NavControl.ShowPage(Page1)

End Sub

Then Button:

B4X:
Sub Start_Click

Page2.Initialize("Page2")

        Page2.Title = "XD"
    Page2.RootPanel.LoadLayout("Start")
    Page2.RootPanel.Color = Colors.White
    Page2.RootPanel.LoadLayout("Game")
    NavControl.ShowPage(Page2)
    Timer1_Tick
End Sub
And I want that, when I click on a Button Layout START dissapers and there is Layout Game on the screen.

What is the code to close an app? Sth like End?
Thanks,
c
 

Darren69

Member
Licensed User
Longtime User
Hi there,
I am pretty sure you have to define all your pages that you want to load in the Sub Application Start section, and then you just show the page when the button is pressed - so take all this code..

Page2.Initialize("Page2")

Page2.Title = "XD"
Page2.RootPanel.LoadLayout("Start")
Page2.RootPanel.Color = Colors.White
Page2.RootPanel.LoadLayout("Game")

and put it in to the Sub Application Start section and just call

NavControl.ShowPage(Page2)

in your Sub Start_Click routine
 
Upvote 0

carchek

Member
Licensed User
Longtime User
Hi!
Thanks for the help, but when i Run your code I see Start layout beneath Game layout. And it is fcked up.
Is there any way to hide the Start layout when I press the button?
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
You dont need to end your app or create a second page

Just call in your button click event:

Page1.rootpanel.removeallviews

And then load your layout:

Page1.rootpanel.loadlayout("game")

Regards, ilan

Ps: note that if you resize your views via code you will need to resize your new layout again because the page_resize event is called only on app start and when screen size change like from landscape to portrait. (This should be very easy to implement)


Oh, and please use a clean language in this forum.
 
Last edited:
Upvote 0
Top