android-optionsmenu

Toggling state of Wifi on Options menu

纵饮孤独 提交于 2019-12-12 02:18:24
问题 I would like to toggle the state of Wifi in options menu in Android. I would like to extend its functionality by showing two icons one for "switched on" and the other for "switched off". It should work in such a way that when a user presses the menu key: He should see current status of Wifi "on" or "off" The icons must be shown according to its state "on" or "off" When the user clicks the Wifi option it should toggle the state of Wifi and also change the icon accordingly Is this possible to

How to manipulate the Activity's Options Menu

元气小坏坏 提交于 2019-12-11 19:23:46
问题 I've Googled and come up with no code on how to manipulate what the settings button does, or what is brought up when the settings touch button on the phone is pressed. Here is a screenshot of what I mean: At the bottom, you can see that it says settings, but when I click on it, nothing happens. I want to change what happens when it is clicked. Also, I want to be able to change what is brought up (the settings option in the screenshot is what's brought up) when the settings button on the

OpenOptionsMenu not working with ActionBarSherlock Custom SubMenu

可紊 提交于 2019-12-11 03:39:16
问题 In my application, I am using ActionBarSherlock 4.4. Since ForcedOverflow has been removed from the latest version, I used the following XML code to replicate the OverflowMenu. <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/menu_overflow" android:icon="@drawable/abs__ic_menu_moreoverflow_holo_dark" android:orderInCategory="100" android:showAsAction="always"> <menu> <item android:id="@+id/action_settings" android:showAsAction="never" android:title="

onCreate Options menu is not showing in android 3.1

半世苍凉 提交于 2019-12-10 20:44:39
问题 i am creating an app only for tablets. I have a preference activity page which i am calling through the OnCreateOptions Menu. The oncreateoptins menu is not working in tablets of android 3 version. Why it is so, i used a Samsung galaxy tab for my testing. When i run the same app in one of my emulator of Samsung galaxy tablet of android 2.2 i am getting the oncreate options menu, can anyone help me in this 回答1: I think problem is in different handling of options menu. According to dev guide,

OptionsMenu items common for multiple activites

…衆ロ難τιáo~ 提交于 2019-12-10 10:34:40
问题 The Android design guide says that Help should always be placed as the last item of the overflow menu (it should never appear in the ActionBar) and also, that is should be present in every activity, so that users don't have to look for it. Similar approach is also recommended for Settings. However, I'm wondering what is the best way to make sure that all the activities in my app handle these items without lots of code repetition? Putting these common items manually into every XML menu file

Changing options menu icon in actionbar depending on an open Fragment

不羁的心 提交于 2019-12-10 01:08:39
问题 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

Options Menu does not appear in Action Bar on some devices

六眼飞鱼酱① 提交于 2019-12-07 13:24:11
问题 I have an options menu in the action bar, and it does not appear on certain devices which have hardware menu button. I must make it appear in the action bar despite having a hardware button... How can I do it? 回答1: Put this in your onCreate method: try { ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class .getDeclaredField("sHasPermanentMenuKey"); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config,

Android Studio: Is it possible to trigger hardware menu button

久未见 提交于 2019-12-06 12:12:11
I have an android application which kind of like a home screen of the build-in screen on android phone. I can list all the available applications and run them. One thing I don't know how to do is when user run an application from my apps, my application can trigger the hardware menu button to show the current application menus. Is this possible ? If not, what about doing it if the device was rooted. In activity use override onKeyDown like this : @Override public boolean onKeyDown(int keycode, KeyEvent e) { switch(keycode) { case KeyEvent.KEYCODE_MENU: doSomething(); return true; } return super

Android: change width of overflow menu

◇◆丶佛笑我妖孽 提交于 2019-12-06 03:04:25
问题 Currently I have an overflow menu which has default width: What I want is: I have tried changing the theme this way: <style name="MyWorkspaceDetailTheme" parent="@android:style/Theme.Holo.Light.DarkActionBar"> <item name="android:popupMenuStyle">@style/MyPopupMenu</item> </style> <style name="MyPopupMenu" parent="@android:style/Widget.Holo.ListPopupWindow"> <item name="android:dropDownWidth">30dp</item> </style> but didn't got any success. Please can anyone help. 回答1: I was follwing this[http

How to open OptionsMenu on tablet?

◇◆丶佛笑我妖孽 提交于 2019-12-06 02:13:58
I have developed an android app that mainly targets smartphones. However in tablet emulator I see that it works on android 3.x, too. However there is one little problem. The user cannot open OptionsMenu when he clicks on the menu button. As you know on the smartphone a menu appears from the bottom. But on tablet nothing happens. I have read this http://developer.android.com/guide/topics/ui/menus.html#options-menu but still cannot figure out how to manage this. My app has a custom action bar. My code is quite straight forward. In main activity: @Override public boolean onCreateOptionsMenu(Menu