BlackBerry Forums Support Community
              

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

Please Login to Remove!

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)
Offline  
Old 07-21-2008, 04:52 PM   #2
Dougsg38p
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Default

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.
Offline  
Old 07-21-2008, 05:09 PM   #3
Ivanov
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Default

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

Thank you.
Switching to addMenuItem worked.

Is it a better idea to override MakeMenu?
Offline  
Old 07-21-2008, 05:53 PM   #5
Ivanov
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Default

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..
Offline  
Old 07-22-2008, 11:12 PM   #6
flameheels
New Member
 
Join Date: Jul 2008
Model: 8800
PIN: N/A
Carrier: MTS
Posts: 9
Default

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.
Offline  
Closed Thread



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Intel SE7520JR2  Server Board FOR XEON PROCESSOR W/ BOX picture

Intel SE7520JR2 Server Board FOR XEON PROCESSOR W/ BOX

$150.00



Intel SE7500WV2 SCSI Server Board FOR XEON PROCESSOR W/ BOX picture

Intel SE7500WV2 SCSI Server Board FOR XEON PROCESSOR W/ BOX

$150.00



Intel SE7501WV2 SCSI Server Board FOR XEON PROCESSOR W/ BOX picture

Intel SE7501WV2 SCSI Server Board FOR XEON PROCESSOR W/ BOX

$150.00



INTEL XEON E5 2520V2 E5 2620V2 SR1AN 2.10 GHZ Core Processor 3401A832 picture

INTEL XEON E5 2520V2 E5 2620V2 SR1AN 2.10 GHZ Core Processor 3401A832

$12.00



NETWORK INSTRUMENT GIGASTOR- 2U (2X) XEON E5-2630- 64 GB PC3 RAM picture

NETWORK INSTRUMENT GIGASTOR- 2U (2X) XEON E5-2630- 64 GB PC3 RAM

$293.99



Trenton 92-506313-XXX W/ 2x Intel Xeon Processors & 4GB DDR2 RAM picture

Trenton 92-506313-XXX W/ 2x Intel Xeon Processors & 4GB DDR2 RAM

$110.00







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.