View Management

Hi guys, 

I'm at the stage where I have a number of views that have been pushed, and need some advice about managing the views, and what the push command is actually doing..

For example, as I navigate the pages, should I be pushing:   new viewname()  all the time, or is this actually loading several copies of the same view?

When should I use switch view ? I assume that this will display a view that is onhide, back to onshow that has all ready been pushed?

If I switch view something that has not been pushed, what does it call?

Likewise, if I pop view.... what is actually happening in the code, is it moving the visible view down the stack, or is it off the stack completely?

... The Monkey C notes don't really explain this any further than the slang that is describing the function title... popping off the stack , or  pushing a new view.


  • Think of views as pieces of paper.  Lay down a page, and that's the main view.  Each time you push a view, add another sheet of paper, each time you pop a view, take one away..  That's your view stack.  The page on top is your current view - the only one you see.  Take it away (pop it) the page under it becomes the current view.  In a device app, if you pop the main view, the app exits.

    You don't want this pile to get too deep - due to memory. (and it can be confusing).

    Lets say you have 2 views (and the main view).  In the main view you push view1.  When leaving view1, you will probably want to pop it before you push view2, unless you want view1 to be active when you pop view 2.

    you can make things simpler and just have a main view, and then use page numbers to indicate which screen to display in onUpdate() and only push/pop things like a menu view.

  • Ok, but by default I'm not using Main or layouts in the res, what dictates the main view.... is it simply the first page that loads from the app?  

    If I have all my calculations running on the main view, that are displayed on other pages then I should pop the other ones, and switch to view back to the main to get back in there?


  • You can use layouts for views, but views don't need layouts.

    Your main/top/initial view is generated by way of getInitialView() in your AppBass class.

    When are you creating other views?