menuitem

onOptionsItemSelected() not called when clicking on menu item which has an actionLayout set on it

拥有回忆 提交于 2019-12-19 08:11:07
问题 In my action bar, I have defined a menu item that can show text "DONE" by the code below: Menu.xml: <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/action_register_text" android:actionLayout="@layout/action_done_text" android:title="@string/action_done" android:showAsAction="always"/> </menu> action_done_text.xml: <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/expand

How to change programmatically background color of action bar items

可紊 提交于 2019-12-19 07:09:26
问题 It is easy to set a default color of the items background in action bar by setting: <item name="android:actionBarItemBackground">@drawable/action_bar_item_background</item> in application theme. I would like to change this color only for one of my fragments. How to do it programmatically? 回答1: Have you tried the solution from user3225831 mentioned here: https://stackoverflow.com/a/21297231/1738838 ActionBar bar = getActionBar(); bar.setBackgroundDrawable(new ColorDrawable("COLOR")); 回答2: Use

Is there a way to programatically close a menuitem in WPF

落花浮王杯 提交于 2019-12-19 05:56:08
问题 I have a menu in wpf that has an input box and a button on it. Once the user clicks the button I need to close the menu. Is there a way to do this? <Menu x:Name="MainMenu"> <MenuItem Header="Main"> <MenuItem Header="SubMenu" x:Name="SubMenu"> <StackPanel Orientation="Horizontal"> <TextBox Width="50" x:Name="TextBox" /> <Button Content="Click Me and Close" x:Name="Button" IsDefault="True"/> </StackPanel> </MenuItem> </MenuItem> Thanks, Jon 回答1: Get hold of the MenuItem and do: _menuItem

Gmail tablet like Actionbar items

二次信任 提交于 2019-12-18 19:17:04
问题 I'm trying to build an app with a split actionbar/toolbar like in the Gmail app. Is there any view element for this behaviour or do I have to write such a toolbar myself? The search icon is moving with the master fragment when opening the slidingDrawer . 回答1: To accomplish this you can add one of the new Toolbar widgets to each of your fragments layouts. The new Toolbar class was designed to be much more flexible than a traditional Actionbar and will work well in this split design. This post

How To Get Action View Of Menu Item?

独自空忆成欢 提交于 2019-12-18 16:49:14
问题 This is My Code home.xml <item android:id="@+id/action_shopping_cart" android:actionLayout="@layout/action_bar_cart_button" android:showAsAction="ifRoom" android:title="Shopping Cart" /> <item android:id="@+id/action_notifications" android:actionLayout="@layout/action_bar_notifications_button" android:showAsAction="ifRoom" android:title="Notifications" /> <item android:id="@+id/menu_overflow" android:orderInCategory="100" android:icon="@drawable/ic_action_overflow" android:showAsAction=

WPF - how to hide menu item if command's CanExecute is false?

独自空忆成欢 提交于 2019-12-18 10:58:24
问题 By default menu items become disabled when its command cannot be executed (CanExecute = false). What is the easiest way to make the menu item visible/collapsed based on the CanExecute method? 回答1: You can simply bind Visibility to IsEnabled (set to false on CanExecute == false). You still would need an IValueConverter to convert the bool to visible/collapsed. public class BooleanToCollapsedVisibilityConverter : IValueConverter { #region IValueConverter Members public object Convert(object

Android: background color when menu item is pressed

旧城冷巷雨未停 提交于 2019-12-18 08:35:27
问题 I'm trying to change the background color to the menu item when it is pressed. Change the background color but not the color when pressed. WHISED: Background: dark gray Background pressed: orange OBTAINED: Background: dark gray Background pressed: blue (default Android) What I can do? Thanks Styles.xml <style name="AppTheme2" parent="android:Theme.Holo"> <item name="android:popupMenuStyle">@style/MyApp.PopupMenu</item> </style> <style name="MyApp.PopupMenu" parent="android:Widget.Holo

Android: background color when menu item is pressed

放肆的年华 提交于 2019-12-18 08:35:09
问题 I'm trying to change the background color to the menu item when it is pressed. Change the background color but not the color when pressed. WHISED: Background: dark gray Background pressed: orange OBTAINED: Background: dark gray Background pressed: blue (default Android) What I can do? Thanks Styles.xml <style name="AppTheme2" parent="android:Theme.Holo"> <item name="android:popupMenuStyle">@style/MyApp.PopupMenu</item> </style> <style name="MyApp.PopupMenu" parent="android:Widget.Holo

Two line text for MenuItem

▼魔方 西西 提交于 2019-12-18 07:42:47
问题 Do you know how to have a two lines menu item title? I've tried using \n in the string or Html.fromHtml with tag but it doesn't work. Thanks 回答1: This is the recommended answer from Google: "If text in a simple menu wraps to a second line, use a simple dialog instead. Simple dialogs can have rows with varying heights." https://material.io/guidelines/components/menus.html#menus-simple-menus 回答2: You can use String line=System.getProperty("line.separator") this will give you newline effect in

WPF C# - Change the brush of a menu's background

╄→гoц情女王★ 提交于 2019-12-18 04:42:33
问题 Does anyone know how to change the brush for a menu's background? This sounds simple, but I don't see any obvious way to do this. You'd think that the Background property would change it, but it doesn't. Here's what my menu looks like (notice the default white background): Example Code: <Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300">