Im having trouble adding a menuitem to the mainscreen menu
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) |
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.
|
you can also use public void addMenuItem(MenuItem item) if you are not overriding makeMenu()
|
Thank you.
Switching to addMenuItem worked. Is it a better idea to override MakeMenu? |
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() |
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.
|
All times are GMT -5. The time now is 04:19 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.