menuitem

How to create a Menu instance programmatically? i.e. inflate a Menu outside onCreateOptionsMenu

只谈情不闲聊 提交于 2019-12-09 04:12:04
问题 I want to inflate a menu object outside onCreateOptionsMenu method (which means to create/show the menu when the user doesn't press the button), so I need to create a menu instance to pass it to the inflate method. Here is an example of what I am trying to achieve: Menu menu = // How to create an instance !? new MenuInflater(context).inflate(R.menu.my_menu, menu) Menu is an interface, so I need to know which class is implementing it. I did browse Android code to get any hint on how a Menu

android:onClick set on menuitem in xml

人盡茶涼 提交于 2019-12-08 19:06:26
Dear can we use onclick with menu item in xml. like below .i tried it but its not working. <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/logout" android:onClick="onLogOut" android:title="@string/logout"> </item> Java Code : public void onLogOut(MenuItem v) { Utility.LogError(TAG, "onLogOut Clicked"); Toast.makeText(this, "onLogOut", Toast.LENGTH_SHORT).show(); } } onLogOut is not get called.... use android:onClick="onLogOutClick" instead of android:onClick="@string/onLogOutClick" for adding onclick with menu item and And in Java we should write the

TinyMCE Create sub-menu in context menu

核能气质少年 提交于 2019-12-08 11:31:44
问题 I have created two context menus in TinyMCE editor.addMenuItem('insert_element', { text: 'Insert', onclick: insert_action, }); editor.addMenuItem('insert_fig', { text: 'Figure', onclick: insert_figure, context: 'insert_element', prependToContext: true }); and passed the context menus in tinymce.init ... tinymce.init({ ... contextmenu: "insert_element,insert_fig", ... }); ... Now on right clicking in active text area, i got two menus as "Insert" and "Figure". I would like to change the "Figure

Set Statusbar Text on Mouse Hover - Works for controls but not MenuItems

亡梦爱人 提交于 2019-12-08 10:45:06
问题 I devised the following code for displaying a control's Tag property on mouseover. The code works fine for standard controls such as Labels and TextBoxes but I cannot get it to work for my MenuItems (more specifically ToolStripMenuItems). Could y'all please take a look at my code and tell me what I did wrong? Thanks in advance! public void Form1_Load(object sender, EventArgs e) { ... this.addEventsToAllComponents(this); } private void addEventsToAllComponents(Component component) { if

Multiple documents open at the same time, each with different menu item states

喜你入骨 提交于 2019-12-08 08:21:41
问题 In a Cocoa document-based application, what's the best way to keep the menu item states in the menu bar in sync with the currently visible document? For example, say you have a document with a ruler view that can be hidden/shown via "Show Rulers" (off state) and "Hide Rulers" (on state) menu items. The user has two documents open at the same time. He/she has hidden the rulers in one document, but not on the other. When the user moves between the documents the menu item should reflect the

Switch between multiple views in the same viewcontroller

▼魔方 西西 提交于 2019-12-08 08:10:19
问题 I'm using the Side-out-Navigation-panel in this example and it is easy for me. Now I want to do it in storyboard and I want when select item from list panel to switch between different views in the centerViewController like uitableView or uiview. exactly like facebook. how can I make switch between different views in the same viewController? Hope anyone got my mean. Thanks in advance. 回答1: [UIView transitionFromView:self.someView toView:self.tableView duration:.5 options

cocoa how to block the “Quit” menu item on dock menu

爷,独闯天下 提交于 2019-12-08 07:37:36
问题 my dock menu always be added "Quit" and other 2 menu items automatically, how may I block / modify them? updated: really NO way to delete/block/redirect the "Quit" menu item. used Peter's recommendation at last like blow hope helpful to others -(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { if (needPassword) { [self checkPassword:self]; return NSTerminateCancel; } else { return NSTerminateNow; } } -(void)checkPassword:(id)sender { if(passwordCorrect) {

ASP.NET: How to set the cssclass for a menuitem on codebehind

烈酒焚心 提交于 2019-12-08 07:33:37
问题 How can I set a different cssclass for each menuitem of a ASP.NET Menu control from codebehind? All of these menuitems are at level2. So something like this would not work because all of the menuitems on level2 would end up with the same cssclass(level2class) and I want to be able to set diferent styles for each of them: <LevelMenuItemStyles> <asp:MenuItemStyle CssClass="level1class"/> <asp:MenuItemStyle CssClass="level2class"/> </LevelMenuItemStyles> So I'd like to do something like this:

WPF Binding ContextMenu MenuItem's ItemsSource

别等时光非礼了梦想. 提交于 2019-12-08 07:00:26
问题 I'm trying to bind a single MenuItem's ItemsSource to a ReadOnlyCollection<string> located in the ViewModel. I've read that the ContextMenu is not under the main Visual tree so i can't bind it directly, but any method i try doesn't work. I have the code snippet please let me know what am i doing wrong. <Window> … <DockPanel> <!-- Task bar Icon --> <tb:TaskbarIcon x:Name="AppNotifyIcon" DataContext="{Binding Path=DataContext, RelativeSource={RelativeSource AncestorType={x:Type Window}}}"

Multiple documents open at the same time, each with different menu item states

故事扮演 提交于 2019-12-08 05:08:29
In a Cocoa document-based application, what's the best way to keep the menu item states in the menu bar in sync with the currently visible document? For example, say you have a document with a ruler view that can be hidden/shown via "Show Rulers" (off state) and "Hide Rulers" (on state) menu items. The user has two documents open at the same time. He/she has hidden the rulers in one document, but not on the other. When the user moves between the documents the menu item should reflect the state for that document, not for the application as a whole. How does one do this cleanly? I've googled