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: 103
Registered: ‎12-12-2011
My Device: Developer
My Carrier: Robosoft

Change text of menu item.

Hello all,

          I want to change the text of menu item in the menu added to a screen. I have added the menu items to the menu overriding makeMenu(), code is given below:

                                           

protected void makeMenu(Menu menu, int instance) {
        super.makeMenu(menu, instance);
        if(!mIsRelatedStory){
            menu.add(new MenuItem("A", 0, 1) {
                
                public void run() {
                   //Code
                }
            });
        }
        
        menu.add(new MenuItem("B", 0, 2) {
            
            public void run() {
                // TODO Auto-generated method stub
            }
        });
        
        menu.add(new MenuItem("C", 0, 3) {
            
            public void run() {
                // TODO Auto-generated method stub
                
            }
        });
        
        menu.add(new MenuItem("D", 0, 4){
            public void run() {
               //TODO
            };
        });
        
    }

 

Now  I want to change the text of menu item "D" to "E", when clicked on it and i need to save that status i.e. text to remain as "E", if I revisit the screen again and if clicked on it back, the text has to be changed back to "D" and again have the status saved.

I went though some of the posts in forums, but could not get appropriate answer for my problem. Can someone throw light on the problem? Thanks in advance..

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

Re: Change text of menu item.

There are two issues here:

a) How to store a value persistently

b) how to use that value as text in a menu item.

 

The second is easy, you can set the Text in makeMenu as you currently do, but rather than setting it to a literal, you can set to the value you have saved.  So the only trick is saving a value and getting it back.

 

If you search for "persistent" you will find a number of KB articles and tutorials that will help, including this one:

http://supportforums.blackberry.com/t5/Java-Development/Introduction-to-Persistence-Models-on-BlackB...