android-optionsmenu

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

Android options menu icon won't display

烈酒焚心 提交于 2019-11-26 20:46:53
I'm following a book on Android Development to get myself started writing my first real app. I got up to the point where I'm making an options menu for one of my activities. The menu shows up, but the corresponding icon of the menu item refuses to display. Here is the code for the menu: ReminderListActivity @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); MenuInflater mi = getMenuInflater(); mi.inflate(R.menu.list_menu, menu); return true; } res/menu/list_menu.xml <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com

Toolbar options menu background color

北慕城南 提交于 2019-11-26 16:17:01
问题 I am using the toolbar for android. I just want to change the background color of the overflow menu. But it is not changing. Style xml <style name="MyDarkToolbarStyle" parent="Widget.AppCompat.Toolbar"> <item name="popupTheme">@style/PopupMenuStyle</item> <item name="theme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item> </style> <style name="PopupMenuStyle" parent="android:Widget.Holo.Light.PopupMenu"> <item name="android:popupBackground">@android:color/white</item> </style> Toolbar XML

How to change option menu icon in the action bar?

≯℡__Kan透↙ 提交于 2019-11-26 12:39:21
问题 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\" /> 回答1: The

Clicking hamburger icon on Toolbar does not open Navigation Drawer

烂漫一生 提交于 2019-11-26 11:38:01
问题 I have this nav drawer which was working perfectly fine. Refactoring my code I removed all onOptionsItemSelecteds in activities and made all activities inherit from a base activity which extends AppComplatActivity and implements all the necessary methods. After this clicking on hamburger icon does not work any more even though I have syncstate () and every thing. Any clues why this is not working? One of the activities: public class MainActivity extends BaseActivity implements

Android Options Menu in Fragment

那年仲夏 提交于 2019-11-26 11:01:19
I am trying to add an item to the options menu from a group of fragments. I have created a new MenuFragment class and extended this for the fragments I wish to include the menu item in. Here is the code: public class MenuFragment extends Fragment { MenuItem fav; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true); } public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { fav = menu.add("add"); fav.setIcon(R.drawable.btn_star_big_off); } } For some reason the onCreateOptionsMenu appears not to run. Kuffs Call the