menuitem

Is it possible to grey out (not just disable) a MenuItem in Android?

…衆ロ難τιáo~ 提交于 2019-11-28 16:40:04
问题 There's a question for the same functionality on Blackberry, and a few different threads referred to this bug (which has since been closed without resolution as far as I can tell), but I haven't found one specifically for Android. I'm calling setEnabled(false) on certain MenuItems based on some state, but they visually look the same. I'd like them to be offset in some way, so that the user knows that the option currently isn't available -- is there any way to do that? 回答1: I had the same

Android Studio: invalidateOptionsMenu() causes the always visible items to stop working

只谈情不闲聊 提交于 2019-11-28 12:48:05
问题 I am trying to hide/show an always visible item ( app:showAsAction="always" ) of a menu after a Switch is off/on. The issue is: if I use invalidateOptionsMenu() in onPrepareOptionsMenu() , my searchView and savebutton menu.findItem(R.id.save_product_option) stop working. They are visible but do not answer to the click. If I do not use invalidateOptionsMenu() , the items work as expected. But the savebutton only gets hiden ( menu.findItem(R.id.save_product_option).setVisible(false) ) when I

Showing Custom Layout on Overflow Drop Down Menu Item? Android

二次信任 提交于 2019-11-28 11:06:39
I am trying to figure out how to show a custom view for items inside the overflow menu (on right of actionbar) but I can't seem to figure it out. It still shows the title only :S. I want to do something like how twitter has it to show an icon, title, and subtitle in the first item in drop down menu. Can anyone help me out Item in Menu.xml <item android:id="@+id/action_dropdown" android:icon="@drawable/ic_action_overflow" android:actionProviderClass="efwefwef.com.actionbar.ABDropDown" android:title="" android:showAsAction="always"> </item> actionProvider Class #1 public class ABDropDown extends

How to include a common menu item in multiple menus in Android menu xml?

和自甴很熟 提交于 2019-11-28 10:42:13
Many of menus have always one item same to all. Is there the way to define that item as extra menu and include it to all other? Something like this: menu/main.xml <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/menu_main" android:title="@string/text_mainmenu" /> </menu> menu/other.xml <menu xmlns:android="http://schemas.android.com/apk/res/android" parent="@menu/main"> <item android:id="@+id/menu_other" android:title="@string/text_othermenu" /> </menu> I know, that it's possible to do it programmaticaly, but I thought xml-way is nicer. AFAIK, <include>

WPF window image updating from menuitem but not when in while loop

家住魔仙堡 提交于 2019-11-28 10:32:31
问题 Okay, this is a real head-scratcher: If I select a menuitem that causes the image, that makes up the entire window (a writeableBitmap) to have some pixels drawn on it, it does so and displays correctly. However, if I add a while loop (let's say for 5 loops) to the same method the drawing on the bitmap DOES NOT DISPLAY until the loop is completed and then the 5th redrawn bitmap is correctly displayed. So, is there some sort of 'automatic refresh' that is happening to the window when a menuitem

How can I capture a long press on a Menu Item?

你。 提交于 2019-11-28 08:56:27
问题 I have a typical menu and I'm wanting to set a onLongClickListener for one of the items. In other words, I want this item to perform it's normal onOptionsItemSelected function, as well as, a long press function. MenuItem item; item = menu.findItem(android.R.id.home); item.setOnLongClickListener(new OnLongClickListener() { public boolean onLongClick(View v) { Context context = getApplicationContext(); CharSequence text = "Long Press"; int duration = Toast.LENGTH_SHORT; Toast toast = Toast

Navigation Drawer Menu Item Title Color in Android

无人久伴 提交于 2019-11-28 08:25:45
I have a problem changing the Menu Item Title Color in the Navigation Drawer I set the itemTextColor but it only changes the Color of the Items not the Title of the menu. Here is my Activity_main.xml <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:openDrawer="start">

WPF : MenuItem.CommandParameter binding set to null

这一生的挚爱 提交于 2019-11-28 08:00:10
问题 I have the following ContextMenu defined for my data grid: <igDP:XamDataGrid.ContextMenu> <ContextMenu ItemsSource="{Binding CommandViewModels}" > <ContextMenu.ItemContainerStyle> <Style TargetType="MenuItem"> <Setter Property="Command" Value="{Binding Command}" /> <Setter Property="CommandParameter" Value="{Binding CommandParameter}" /> <Setter Property="Header" Value="{Binding Name}" /> <Setter Property="Icon" Value="{Binding Icon}" /> </Style> </ContextMenu.ItemContainerStyle> <

Is there a standard way to add dividers between action bar items in Android 3.0?

血红的双手。 提交于 2019-11-28 06:33:22
I have a slight problem trying to customise the look of the action bar in my app. I want to be able to have the pixel wide dividers to group action bar items that you see in many of the native apps (e.g. Gmail, Calendar). I found a way to do this by adding a menu item and setting the 'android:actionLayout' attribute to a custom layout for the divider: <View android:background="@color/LightGray" android:layout_marginTop="5dip" android:layout_marginBottom="5dip" android:layout_width="1dip" android:layout_height="fill_parent" /> This works nicely, but the issue is it counts as a menu item and the

WPF setting a MenuItem.Icon in code

与世无争的帅哥 提交于 2019-11-28 05:18:04
I have an images folder with a png in it. I would like to set a MenuItem's icon to that png. How do I write this in procedural code? Timothy Fries menutItem.Icon = new System.Windows.Controls.Image { Source = new BitmapImage(new Uri("images/sample.png", UriKind.Relative)) }; Arcturus <MenuItem> <MenuItem.Icon> <Image> <Image.Source> <BitmapImage UriSource="/your_assembly;component/your_path_here/Image.png" /> </Image.Source> </Image> </MenuItem.Icon> </MenuItem> Just make sure your image in also included in the project file and marked as resource, and you are good to go :) IanR Arcturus's