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

Reply
Developer
redpath
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
MSohm
Posts: 14,752
Registered: ‎07-09-2008
My Device: BlackBerry Passport

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.
Found a bug? Report it using Issue Tracker
Developer
redpath
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?

 

BlackBerry Development Advisor
MSohm
Posts: 14,752
Registered: ‎07-09-2008
My Device: BlackBerry Passport

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.
Found a bug? Report it using Issue Tracker
Developer
redpath
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
peter_strange
Posts: 19,609
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
redpath
Posts: 62
Registered: ‎07-29-2008
My Device: Not Specified

Re: Screen and Menus (NewBi)

Thanks thats perfect