Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Cascades Development

Reply
New Member
occipitaldanny
Posts: 1
Registered: ‎06-22-2012
My Carrier: Sprint

Best Practices for Switching between Views

I have several discrete screen I'd like to show in my app.  To the best of my knowledge, different screens are set via the 


Application::setScene(mainPage);

 

call.  However, I've had lots of troubles at different parts using this method.

 

For example

 

Application::setScene(mainPage) -> "Open Gallery" button click invokes Application::setScene(galleryView)  -> "Close Gallery" button click invokes Application::setScene(mainPage)

 

Not only does this scare me about the possibility of memory leaks, but this method invokes a crash saying I haven't deallocated the ListView contained in galleryView correctly.

 

What am I missing here?  It looks like NavigationPane solves part of this problem, but I don't want the Navigation UI that comes along with it.  I've also heard something about a concept of Sheets in the upcoming build?  Should I be waiting on that?

 

Thanks,

-dp

Please use plain text.
BlackBerry Development Advisor
smacmartin
Posts: 499
Registered: ‎05-07-2012
My Carrier: developer

Re: Best Practices for Switching between Views

This is related to http://supportforums.blackberry.com/t5/Cascades-Development/NavigationPane-Action-Items-from-a-centr...

 

Two choices immediately come to mind:

1. A NavigationPane with a standard background + current page.  Pop current page, push new page.

2. A Pane.   setContent to change the contents.  Bear in mind that the pane will own the content.  For small number of screens you could just keep a list of them and set the appropriate one.  For large number, you might want to do some double-buffering or have a limited cache of pre-built pages.

 

If there are other approaches I'd love to hear them so I can add them to my arsenal.

 

Stuart

Please use plain text.
Developer
blackqtcoder
Posts: 136
Registered: ‎05-18-2012
My Carrier: Telefonica Spain

Re: Best Practices for Switching between Views

[ Edited ]

How this ? :

-------------------------

 

Page {

     content: Container {

           SegmentedControl {

                  Option { id: option1; text: "Container1"; value: "option1"; selected: true }
                  Option { id: option2; text: "Container2"; value: "option2" }

                  onSelectedIndexChanged: {

                         if (selectedIndex == 0) {

                               cnt2.visible = false;

                               cnt1.visible = true;

                         }

                         else if (selectedIndex == 1) {

                               cnt1.visible = false;

                               cnt2.visible = true;

                         }

                  }

 

          } // SegmentedControl

 

         Container {

              id: cnt1

         }

 

         Container {

              id: cnt2

         }

} // Container

} // Page

 

---------------

 

Yeah, visible() is your friend. :Yes:

 

 

 

---------------------------------------------------------------
Duantox founder, TapyHold developer
TapyHold multimedia scrapbook
Please use plain text.