android-menu

How to change option menu icon in the action bar?

北城以北 提交于 2019-11-27 03:30:17
How to change the index icon of option menu? I mean icon (3). Here is my code: @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.options, menu); return true; } And here is the XML file: <item android:id="@+id/Bugreport" android:title="@string/option_bugreport" /> <item android:id="@+id/Info" android:title="@string/option_info" /> <item android:id="@+id/About" android:title="@string/option_about" /> Syed Raza Mehdi The following lines should be updated in app -> main -> res -> values -> Styles.xml <!-- Application theme.

Action Bar menu item text color

泪湿孤枕 提交于 2019-11-27 03:19:30
How to change text color of menu item title. I tried to change it as below <style name="Theme.Kanku.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title"> <item name="android:textColor">@color/white</item> </style> But it change color only of Action Bar title text, but not menu item text. Try something like this : <style name="ThemeName" parent="@style/Theme.Sherlock.Light"> <item name="actionMenuTextColor">@color/white</item> <item name="android:actionMenuTextColor">@color/white</item> </style> b00n12 I tried several things but nothing worked for me.

“No resource identifier found for attribute 'showAsAction' in package 'android'”

北战南征 提交于 2019-11-27 01:15:33
I am attempting to update my android application to look better for tablets running Honeycomb. As such, I am targeting version 11 of the SDK (my minSdkVersion = 4). This adds the Honeycomb theme to my app, making it look better. However, I have no way to access my menu options. So, I am attempting to add my menu items as an action bar item with the following in the file in my /res/menu/ folder: android:showAsAction="ifRoom|withText" However, I get the following error: No resource identifier found for attribute 'showAsAction' in package 'android' I tried altering my minSdkVersion number to 11

android.support.v7 with `ActionBarActivity` no menu shows

北战南征 提交于 2019-11-27 00:41:54
问题 In the new update Google has released a new API support library, that supports the ActionBar in API level 7+. I used ActionBarSherlock until this update and I wrote the code to load the menu: @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.activity_main, menu); return true; } and the menu file: <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@

What is orderInCategory in ActionBar menu item & why it is use for..?

拥有回忆 提交于 2019-11-27 00:20:11
问题 Im working on action menu item and its over flow item this is my main_menu.xml <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/menu_search" android:icon="@drawable/search" android:title="@string/start_new_project" app:showAsAction="always" /> <item android:id="@+id/menu_dts_overflow" android:icon="@drawable/ic_action_overflow_round" android:orderInCategory="11111

Item with app:showAsAction not showing

半城伤御伤魂 提交于 2019-11-26 22:13:30
I can't understand why wrong and incompatible (AndroidStudio tells me "Should use app:showAsAction with the appcompat library) code <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/action_search" android:title="@string/action_search" android:icon="@drawable/search" android:showAsAction="always" /> </menu> works perfect, but proper and compatible version like <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" > <item android:id="@+id/action_search" android:title="@string/action_search"

Android, How to create option Menu

谁都会走 提交于 2019-11-26 22:07:40
Here I tried to make option menu, but menu is not displaying on screen, so please guide me where am I doing mistake... MenuTest.java public class MenuTest extends Activity { @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater=getMenuInflater(); inflater.inflate(R.menu.more_tab_menu, menu); return super.onCreateOptionsMenu(menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch(item.getItemId()) { case R.id.feeds: break; case R.id.friends: break; case R.id.about: break; } return true; } } And my XML file is more_tab_menu.xml <?xml version="1.0

Android - Correct use of invalidateOptionsMenu()

徘徊边缘 提交于 2019-11-26 21:06:17
问题 I have been searching a lot on invalidateOptionsMenu() and I know what it does. But I cannot think of any real life example where this method could be useful. I mean, for instance, let's say we want to add a new MenuItem to our ActionBar , we can simply get the Menu from onCreateOptionsMenu(Menu menu) and use it in any button's action. Now to my real question, is following the only way of using invalidateOptionsMenu() ? bool _OtherMenu; protected override void OnCreate (Bundle bundle) {

Android: java.lang.IllegalArgumentException: Invalid payload item type

我是研究僧i 提交于 2019-11-26 20:48:46
问题 Some users tell me about the exception the got: java.lang.IllegalArgumentException: Invalid payload item type at android.util.EventLog.writeEvent(Native Method) at android.app.Activity.onMenuItemSelected(Activity.java:2452) at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:846) at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:153) at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:956) at com.android

How can I dynamically create menu items?

删除回忆录丶 提交于 2019-11-26 19:50:28
I'm building an Android application and I'm trying to build a user management system where users can login, logout, etc. I want to display a login menu item if the user is logged out and a logout button if the user is logged in. How can I do this dynamically? This is the layout file right now: <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/add" android:title="Add" android:icon="@drawable/ic_menu_add"/> <item android:id="@+id/list" android:title="List" android:icon="@drawable/ic_menu_list"/> <item android:id="@+id