Blackberry applications have a "menu" list coming up when you hit the Blackberry menu button. (When you inherit from "MainScreen".) But in my application there is only one entry, "Close".
How do I add entries to this menu?
(This is not a dupe of this question, which is about replacing the standard menu with an entirely custom menu.)
create a menu item using the net.rim.device.api.ui.MenuItem. You can add it to a MainScreen with the addMenuItem(MenuItem item) function.
EDIT
sample code
MenuItem mi=new MenuItem("mymenuitem",1,1);
addMenuItem(mi);
Related
I'm new to android and java and I'm trying to work on an app.
The reason I'm seeking for help is that I can't figure out how to replicate the action of single tapping on an item of a list (action that opens the item) in a context menu (which appears with a long tap on the item). I can't associate the field I created ("Modify item") to actually open the selected item. I can't post any part of the code and I'm sorry about that, hope you might understand and help anyways.
Thanks
I am trying to show a menu on clicking a Direct Tool item on an RCP application.
My Application.e4xmi is designed like this:
I am able to display a menu using,
On Clicking the drop down arrow,aboutToShow() gets executed and displays the menu elements.
#AboutToShow
public void aboutToShow(List<MMenuElement> items) {
//Displays a menu when the drop down link is clicked.
}
On Clicking the area within the marked square, the execute() method of the handler attached with the direct tool item gets executed, but I am not able to get the list of MMenuElement items.
Is there any ways to display the menu elements on clicking the Handled tool item on picture 2?
Possible way of hiding menuItem base on the screen(Activity) is in the foreground. I have four (4) menuItem and I want to show two (2) in the action bar and force 2 into the overflow menu, in some screen I want to show three (3) and have one (1) in the overflow menu,and in some screen the page tile is long I do not want it truncated but instead I want to show only one (1) menuItem in the action bar and force the other three (3) into the overflow menu.
I need a generic way to do this.
I need to do this programmatically I don't need the xml answer of IfRoom, I have a BaseActivity which extends ActionBar and I have BaseActivityHelper where I have my menu layout inflated, all my other activity extends the BaseActivity.
I would love to share my code but I'm not allowed to do so, the big question is if you are the one faced with this situation how will you do it.
The docs say:
If you want to modify the options menu based on events that occur during the activity lifecycle, you can do so in the onPrepareOptionsMenu() method. This method passes you the Menu object as it currently exists so you can modify it, such as add, remove, or disable items. (Fragments also provide an onPrepareOptionsMenu() callback.)
So, you can grab your menu item in onPrepareOptionsMenu and call it's setShowAsAction(int actionEnum) with the appropriate option (SHOW_AS_ACTION_ALWAYS, SHOW_AS_ACTION_IF_ROOM, or SHOW_AS_ACTION_NEVER)
In Eclipse E4, detached view option is not available but this is very important requirement for our project, So i want to add popup menu in MPart to provide the functionality.
Please guide me how can i add popup menu in MPart. I tried adding it in application model but it seems i am doing something wrong.
Thanks in Advance!
Add a popup menu and handled menu item to the MPart in your .e4xmi
Make sure you get the id's correct. The handler will be the code you want to run
see here for an example:
http://www.vogella.com/tutorials/EclipseRCP/article.html#menuadvanced_popup
Am designing an application in java using netbeans, in which i need to call a "Save" function by clicking on the save item on the menu bar. Am able to call the function by having a button inside the main panel, but am not able to call the function when i click on the menu bar or any where else. How can this be done?
Start with How to Use Menus, then see this example of How to Use Actions.
First check if you have defined an actionPerformed() method for the menuitem from which you are trying to call the method. If not, then you can define an actionPerformed() method by right clicking on the menu item in the design frame and select "events>actionperformed" from the context menu. Also take care that the menu items objects should not be a static field.