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
cristian2014
Posts: 32
Registered: ‎03-11-2014
My Device: 8520
My Carrier: 8520
Accepted Solution

Menu Item

Hy guys, I have created some buttons on a screen, and I want them also to appear in the menu.

Here is a buton

ButtonField myButton= new ButtonField("Push me", ButtonField.CONSUME_CLICK);
        myButton.setChangeListener(new FieldChangeListener() {
            
            public void fieldChanged(Field field, int context) {
                UiApplication.getUiApplication().pushScreen(new AnotherScreen));
                
            }
        });

addMenuItem(_viewItem);

 

And here is the menu function. This function just dispaly a message. But I want to put my button here and to have the same function(to send me to another screen). How cand do this? Do i have to declare the button again in this function?

private MenuItem _viewItem = new MenuItem("", 110, 10)
        {
           public void run()
           {
              Dialog.inform("Hello");
           }
        }

 

Thanks in advance

Please use plain text.
Developer
cristian2014
Posts: 32
Registered: ‎03-11-2014
My Device: 8520
My Carrier: 8520

Re: Menu Item

I figure it out. In the run method I repleced the   Dialog.inform("Hello");  with   UiApplication.getUiApplication().pushScreen(new AnotherScreen));.

 

I posted the solution thinking that somene else will encounter this problem.

Please use plain text.