Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

New Member
Posts: 1
Registered: ‎06-22-2012
My Device: Dev Alpha
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 



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?




Posts: 499
Registered: ‎05-07-2012
My Device: developer
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.



Posts: 146
Registered: ‎05-18-2012
My Device: PlayBook & STL100-1 LE Z10 & Dev Alpha C
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.




Leandro Cerdan - Duantox Apps
BlackBerry Elite dev
TapyHold, Built for Blackberry multimedia scrapbook