android-optionsmenu

java.lang.illegalstateexception: a factory has already been set on this layoutinflater

自闭症网瘾萝莉.ら 提交于 2019-11-27 23:52:44
I have tried to change the background color of options menu in my android app. I am using ActionBarSherlock library. I have tried this code for changing the background color of options menu https://stackoverflow.com/a/8475357/584095 But I ended up with an exception "java.lang.illegalstateexception: a factory has already been set on this layoutinflater" at line LayoutInflater.setFactory(); I don't know what is wrong in this code. Can anyone help me in resolving this issue? There been a change in support library since version 22.1.0. You will get an IllegalStateException if you try to call

Android - Correct use of invalidateOptionsMenu()

时光总嘲笑我的痴心妄想 提交于 2019-11-27 22:41:51
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) { _OtherMenu = false; base.OnCreate (bundle); SetContentView (Resource.Layout.Main); Button button =

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

我是研究僧i 提交于 2019-11-27 21:52:28
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.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:534) at com.android.internal.view.menu

Clicking hamburger icon on Toolbar does not open Navigation Drawer

此生再无相见时 提交于 2019-11-27 09:41:25
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 SearchFilterFragment.OnFragmentInteractionListener { NavigationView navigationView; DrawerLayout drawerLayout; private

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.

Pressing menu button causes crash in Activity with no ActionBar

江枫思渺然 提交于 2019-11-27 01:35:41
问题 I'm a newbie in Android and working on my first app. I have the main activity with no ActionBar in it. And I don't want to display any menu in that Activity . Everything is working just fine But when I press the menu button present in the device itself, it causes my app to force close instead of just ignoring it. I'm developing for sdk >=8 so I'm using the support library. I have tried adding OnCreateOptionMenu() in the code with nothing in it but ended up with same results. The name of my

Hide MenuItem in some Fragments

可紊 提交于 2019-11-27 00:40:40
问题 I using menu drawer which has more Fragment s. In some Fragment s I have menu item REFRESH but in some fragments I want hide this menu item (I don't want show menu but I don't want hide ActionBar ). I try add override onCreateOptionsMenu() to Fragment where I don't want show this menu item but I can not get it to work. I try many way see commented line in code. Does any idea where is problem? And last this menu item go to hide when I activate menu drawer when is called onPrepareOptionsMenu()

How to add Action bar options menu in Android Fragments

一个人想着一个人 提交于 2019-11-27 00:39:41
I am trying to have a options menu in Android Fragments . ActionBar options menu are not displaying in my Fragments. Here is my code and I have both onCreateOptionsMenu() and onOptionSelected() function. My code doesn't shows any error. But options menu are not displaying. package org.reachout; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.LinearLayout; import org.general.R; public class ViewMessageFragment extends Fragment { /* (non-Javadoc) * @see android

java.lang.illegalstateexception: a factory has already been set on this layoutinflater

流过昼夜 提交于 2019-11-26 23:21:47
问题 I have tried to change the background color of options menu in my android app. I am using ActionBarSherlock library. I have tried this code for changing the background color of options menu https://stackoverflow.com/a/8475357/584095 But I ended up with an exception "java.lang.illegalstateexception: a factory has already been set on this layoutinflater" at line LayoutInflater.setFactory(); I don't know what is wrong in this code. Can anyone help me in resolving this issue? 回答1: There been a

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) {