BlackBerryForums.com : Your Number One BlackBerry Community      

»Sponsored Links



Reply
 
LinkBack Thread Tools
  (#1 (permalink)) Old
flameheels Offline
New Member
 
Posts: 9
Join Date: Jul 2008
Model: 8800
PIN: N/A
Carrier: MTS
Default Im having trouble adding a menuitem to the mainscreen menu - 07-21-2008, 04:41 PM

Im having difficulty adding a Menuitem to the main screen. Adding the other fields has been no problem. here is the code. Imports are included.

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;

....

MenuItem men = new MenuItem("new item",40,40) {
public void run() {
// title.setText("text here");
}

};
add(men);


the error I get is:
C:\Program Files\Research In Motion\BlackBerry JDE 4.3.0\bin\HelloWorldtest.java:137: cannot find symbol
symbol : method add(net.rim.device.api.ui.MenuItem)
   
Reply With Quote
Sponsored Links
Please Login or Register to Remove these Advertisements!

  (#2 (permalink)) Old
Dougsg38p Offline
Thumbs Must Hurt
 
Posts: 129
Join Date: Mar 2008
Location: Austin, TX
Model: 8320
PIN: N/A
Carrier: T-Mobile
Default 07-21-2008, 04:52 PM

You don't add a menu item to your screen. You add a menu item to your menu. Look at overriding makeMenu() in the Screen class.
   
Reply With Quote
  (#3 (permalink)) Old
Ivanov Offline
Thumbs Must Hurt
 
Posts: 185
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Default 07-21-2008, 05:09 PM

you can also use public void addMenuItem(MenuItem item) if you are not overriding makeMenu()
   
Reply With Quote
  (#4 (permalink)) Old
flameheels Offline
New Member
 
Posts: 9
Join Date: Jul 2008
Model: 8800
PIN: N/A
Carrier: MTS
Default 07-21-2008, 05:15 PM

Thank you.
Switching to addMenuItem worked.

Is it a better idea to override MakeMenu?
   
Reply With Quote
  (#5 (permalink)) Old
Ivanov Offline
Thumbs Must Hurt
 
Posts: 185
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Default 07-21-2008, 05:53 PM

it depends...
if the menu items should be added "dynamicaly" (or the labels changed) depending on some state of the screen it is better to override makeMenu()

Last edited by Ivanov : 07-21-2008 at 05:54 PM.
   
Reply With Quote
  (#6 (permalink)) Old
flameheels Offline
New Member
 
Posts: 9
Join Date: Jul 2008
Model: 8800
PIN: N/A
Carrier: MTS
Default 07-22-2008, 11:12 PM

thank you. I have not tried overiding MakeMenu yet, but I understand that to dynamically adding menuitems would best be done that way. I have found that I can change labels though the other way as well, as long as I declare the menuitems to be within the mainscreen class.
   
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On






Copyright © 2004-2008 BlackBerryNews.com, BlackBerryFAQ.com, BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of Research In Motion Limited.
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.1