天道酬勤,学无止境

menuitem

How to show option menu in android 4.2

I am trying to create menu option in my test application. I am able to see the menu when I set the theme in manifest to just default (The menu shows up in the top). If I set the theme in manifest to NoTitleBar. I can't see the menu option? I want to get the menu when I set theme "NoTitleBar" in manifest. How to fix it? Below are things that I have used in my test application: with Manifest: <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@android

2021-06-15 15:58:26    分类:问答    android   menuitem

How to disable SpreadsheetApp.addMenu item

The SpreadsheetApp.AddMenu(name, array of entries) produces a new menu in the top bar of the spreadsheet. Alternatively, there is the getUI.createMenu that results in an array of items. Both work fine, not sure which is better. Is it possible to disable and enable some of the menu entries depending on what the active sheet is? Is there a way to tell when a particular sheet becomes active? If not, I can work with the onChange or onEdit events since the menu item I want disabled needs to be enabled only when there is a user change to a particular sheet.

2021-06-15 13:23:19    分类:问答    google-apps-script   google-sheets   menuitem

WPF MenuItem IsChecked Binding not working

Anyone know why the menu item binding does not work ? <ToggleButton Name="toggleButton" Checked="checkBoxPublish_Checked" > <ToggleButton.Resources> <converters:BooleanToHiddenVisibility x:Key="boolToVis"/> </ToggleButton.Resources> <Grid> <Image Height="auto" HorizontalAlignment="Left" Margin="5" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="auto" /> <Viewbox > <TextBlock Text="Blocked" Opacity="0.7" Foreground="Red" Visibility="{Binding Path=IsChecked, ElementName=toggleButton, Converter={StaticResource boolToVis}}"/> </Viewbox> </Grid> <ToggleButton.ContextMenu> <ContextMenu

2021-06-14 13:11:52    分类:问答    wpf   menuitem   ischecked

Android: Changing visibility on menu items with changing fragment

I want to change the visibility of menu items of a fragment activity (abs) when ever I change the fragment in the activity. The fragments are SherlockListFragments. The menu items I want to show/hide are spinners I create on menu creation: public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. MenuInflater inflater = getSupportMenuInflater(); IcsSpinner herbSortSpinner = new IcsSpinner(this, null, R.attr.actionDropDownStyle); SpinnerAdapter herbSortSpinnerAdapter = ArrayAdapter.createFromResource(this, R.array.herb_sort_elements

2021-06-14 03:50:50    分类:问答    android   menu   actionbarsherlock   fragment   menuitem

menu.findItem(R.id.*) is null- Android

I am trying to enable/disable a refresh button when certain things happen in my app, but I get a null pointer exception that I can't figure out. I am setting a boolean addingRefresh or removingRefresh to true depending on the situation and then calling invalidateOptionsMenu() to enable or disable the button, however the menu item is returned null. I have searched the internet for why this may be but can't find anything. Code for onCreateOptionsMenu() (called when invalidateOptionsMenu() is called) @Override public boolean onCreateOptionsMenu(Menu menu) { if (addingRefresh) { //below line as

2021-06-13 15:06:24    分类:问答    android   menuitem

ActionBarSherlock hardkey menu panel text color

I have a small question about theming my app that uses ActionBarSherlock. Everything works fine except on Samsung phones with TouchWizz. The overflow menu items appear by pressing the hardware menu key. I know how to change the panel background. My default theme extends Theme.Sherlock.Light.DarkActionBar, so the default menu item text color in the hardware panel will be black, I wan't to change this. Any ideas on how to do this besides changing the parent of my default theme? <style name="Theme.MyApp" parent="@style/Theme.Sherlock.Light.DarkActionBar"> <item name="android:panelBackground">

2021-06-13 12:43:20    分类:问答    android   styles   android-actionbar   actionbarsherlock   menuitem

Changing options menu icon in actionbar depending on an open Fragment

I have this item in my options menu: <item android:id="@+id/opt_mnu_action" android:icon="@android:drawable/ic_dialog_info" android:orderInCategory="1" android:showAsAction="ifRoom" android:title="New"> </item> The menu itself created in main FragmentActivity. I want to change this item's icon programmatically depending on the open Fragment and, obviously, have different actions when the user hits this button. I tried several things to do that, but nothing worked. The last thing I tried was this code in my Fragment's onCreateView method: MenuItem mi = (MenuItem) view.findViewById(R.id.opt_mnu

2021-06-13 11:09:40    分类:问答    android   android-fragments   icons   menuitem   android-optionsmenu

如何通过 id 获取 MenuItem(How to get an MenuItem by id)

问题 我的 res/menu/student_marks.xml 文件中有我的 menuItem: <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" tools:context=".StudentMarks" > <item android:id="@+id/action_selected_year" android:title="@string/action_selected_year" android:showAsAction="withText|ifRoom" style="@style/AppTheme" /> </menu> 现在我需要为这个项目设置一个标题。在我的应用程序的特定部分。 我可以使用此方法处理特定项目: onOptionsItemSelected(MenuItem item) 问题是我需要项目“action_selected_year”而没有这种方法,但在我的程序的另一部分。 我不知道如何得到它。 回答1 Menu optionsMenu; @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater(

2021-06-12 19:33:25    分类:技术分享    android   menuitem

Android:按下菜单项时的背景颜色(Android: background color when menu item is pressed)

问题 我试图在按下菜单项时将背景颜色更改为菜单项。 按下时更改背景颜色但不更改颜色。 希思德: 背景:深灰色背景压制:橙色 获得: 背景:深灰色背景按下:蓝色(默认 Android) 我可以做什么? 谢谢 样式文件 <style name="AppTheme2" parent="android:Theme.Holo"> <item name="android:popupMenuStyle">@style/MyApp.PopupMenu</item> </style> <style name="MyApp.PopupMenu" parent="android:Widget.Holo.ListPopupWindow"> <item name="android:popupBackground">@drawable/menu_item_selector</item> </style> menu_item_selector.xml <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/menu_item_fondo_pressed" android:state_focused="true"/> <item android:drawable=

2021-06-12 17:15:51    分类:技术分享    android   background-color   menuitem

在为 MenuItem 的 ActionView 填充布局时,我应该为 root 传递什么?(What should I pass for root when inflating a layout to use for a MenuItem's ActionView?)

问题 我有一个ImageView作为它的ActionView附加到MenuItem (该项目出现在ActionBar )。 此视图的布局来自 XML。 我是这样膨胀的: ImageView actionView = (ImageView) layoutInflater.inflate( R.layout.action_view_layout, null); 这似乎工作正常。 然而; 在对inflate()的调用中为root传递 null 使 Lint 对我大喊大叫: 避免将 null 作为视图根传递(需要在膨胀布局的根元素上解析布局参数) 在我的特定情况下,我似乎可以在没有 root 的情况下进行管理,但我希望代码尽可能正确。 问题是,我不确定这里应该使用哪个View作为根。 这个答案说它应该是“围绕你想要膨胀的视图对象的小部件”。 但这在这里意味着什么? 用于操作栏的那个? 活动? 完全是别的什么? 更新:阅读答案让我怀疑我正确的做法是: 获取MenuItem对应的ActionBar View 得到它的根将根投射到ViewGroup 将结果传递给充气机 这似乎有效。 任何人都可以确认或否认这是应该做的吗? 回答1 我会简单地这样做: menuItem.setActionView(R.layout.action_view_layout); 让 Android 为您扩充视图。

2021-06-12 03:12:40    分类:技术分享    android   android-layout   menuitem   layout-inflater   actionview