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.

inside custom component

Java Development


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 62
Registered: ‎07-29-2008
My Device: Not Specified

Screen and Menus (NewBi)

I want to create some custom Screen Classes which have content such as MIDlet Forms

then push and pop them away. But I want each screen to have their own Command menu.

The documentation is way to confusing how menus are done. In MIDP, its quite simple

each Form has a command menu associated with it, so when you set the Form to the Display

the command Menu is there with it. I can;t imagine that BB does not have this use case for

the MainScreen class of which I plan on subclassing to achieve my forms to work with as I have

using straight MIDP.

 

For example, lets say this screen is the version Screen that can be displayed if selected from

the main application. But I want it to have its own command menu for example, it should have

Back only or maybe two menu items.

 

class bbVersForm extends MainScreen
{ UiEngine ui;

    public bbVersForm(UiEngine ui)
    {
        super(DEFAULT_MENU | DEFAULT_CLOSE);
        this.ui=ui;
        LabelField applicationTitle = new LabelField("some title");
        setTitle(applicationTitle);
        RichTextField f = new RichTextField("version 1.0");
        add(f);
    }
    public boolean onClose(){
        Dialog.alert("Bye World!");   
        System.exit(0);
        return true;
    }
}
 

BlackBerry Development Advisor
Posts: 15,888
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Screen and Menus (NewBi)

You can modify the menu of a MainScreen by creating MenuItems and adding them using MainScreen's addMenuItem method.  Alternatively you can override the screen's makeMenu method to create a dynamic menu by adding the menu items you wish when the menu is built (occurs each time before the menu is displayed).

 

However, please note that you are not able to mix the User Interface (UI) APIs in the BlackBerry API set.  If you are creating a MIDlet you should use the MIDlet UI classes.  If you are making a BlackBerry CLDC application you should use the BlackBerry specific UI APIs.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Developer
Posts: 62
Registered: ‎07-29-2008
My Device: Not Specified

Re: Screen and Menus (NewBi)

Thanks, I wrapped the menuitem as a MIDP Command and the code works seamlessly for actions.

As for this Push and Pop screen, I just want to set the screen and not have this concept of a stack. Is there a process

for this?

 

Highlighted
BlackBerry Development Advisor
Posts: 15,888
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Screen and Menus (NewBi)

I'm not 100% sure what you are looking for here.  The BlackBerry screen hierarchy is designed to be a stack of screens.  This differs though if you are creating a MIDlet.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Developer
Posts: 62
Registered: ‎07-29-2008
My Device: Not Specified

Re: Screen and Menus (NewBi)

Well then the question I am asking is this, if I am four deep in the stack of screens and I get an error

I want to go back to screen two.This is just an example. So what isa good practice.

 

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Screen and Menus (NewBi)

Not sure this helps, but you don't have to push and pop screens, that is just common practice.  However in some applications I 'swap' screens using code like the following.

 

UiApplication.getUiApplication().popScreen(this);

UiApplication.getUiApplication().pushScreen(newScreen);

 

You could do the same everywhere and so not have a hierarchy.

Developer
Posts: 62
Registered: ‎07-29-2008
My Device: Not Specified

Re: Screen and Menus (NewBi)

Thanks thats perfect