Questions tagged [oncreateoptionsmenu]

112 questions
0
votes
2 answers

Adding Search icon when changed Fragment to Menu

I have a main activity in which you can change fragments, there is a menu with 2 icons which work fine, when i change to the next fragment i want a search icon to be added to the menu. I am new to android development and Xamarin. I have tried using…
0
votes
3 answers

Android Studio MainActivity.java:: error: ';' expected

I am new to Android development, When Android Studio in "MainActivity" class is compiled I get the following error I have pasted the error log…
0
votes
0 answers

Avoid recreation of programmatically created menuitem in fragment

My question is how can I prevent that my programmatically created toolbar menuItem (Menu with submenus) gets overridden with the xml layout every time the fragment resumes. I want to create my expensive toolbar menuitem only when fragment is first…
0
votes
4 answers

oncreateoptionMenu in android toolbar

Hello friends i want to create option menu like below image so i create below menu.xml file:
user3264863
  • 278
  • 4
  • 15
0
votes
0 answers

OnCreateOptionsMenu Null Pointer when resuming application

I am getting a null pointer exception when the app has been in the background and has to create the main activity again when brought to the foreground. The code below is for the overridden activity method onCreateOptionsMenu where I do a few null…
0
votes
4 answers

Android - onCreateOptionsMenu - Can't disable MenuItem from fragment

I'm trying to disable the MenuItem's in my navigationdrawer from my fragment, but it just wont work... Fragment code: @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView =…
0
votes
1 answer

toolbar actions triggering settings menu

i have a toolbar with a typical settings activity attached to the 3 dot menu. In one of my fragments i change the toolbar to add a couple of icons, but when these icons are pressed it runs its method and then launches the typical settings…
Martin Seal
  • 616
  • 2
  • 14
  • 32
0
votes
1 answer

Android Lollipop unintended options menu

All of my activities have no onCreateOptionsMenu or related methods. I deleted the menu.xml and all related ones as well. I still see the options menu on the right side of the bottom bar. Any ideas why this might occur? Min SDK is 10 and the device…
Barışcan Kayaoğlu
  • 1,294
  • 3
  • 14
  • 35
0
votes
0 answers

onCreateOptionsMenu not triggered in fragment

I encounter an issue with one of my fragments which does not trigger at all onCreateOptionsMenu() unlike my other fragments. There is no exception neither or any particular trace and I use the setHasOptionsMenu(true) method. package…
0
votes
3 answers

Android: Unable to hide Menu Item in ActionBar of Child Fragment

PS see the issue before voting down or marking as duplicate.Tried all the possible approaches to hide the menu item but none seems to work. My options_menu.xml is as follows
0
votes
1 answer

Add Options Menu in Android

I have tried to add options menu to my application, but when adding a Create Options Menu to the code it is not used. It looks like this: I used in this page on Fragment Activity and implements Tab Listener. What is the right way to add the…
0
votes
0 answers

Using openOptionsMenu() in onOptionsItemSelected() in fragment

I've got settings button at the right of my actionbar. main.xml from rsc/menu:
0
votes
2 answers

map fragment won't show when using onCreateOptionsMenu

I just added an onCreateOptionsMenu to make an Action Bar for my app. The action bar is working, however the map fragment doesn't fully load. Whereas before it did so. It shows just grey where the map should be. Although the fragment is clearly…
0
votes
0 answers

menu cannot be resolved or is not a field. inflate(R.menu.main, menu)

I know this seems like a duplicate, but it's not. I'm following a tutorial on google maps and I just cannot get throught this fail (notice this is my very first time developing in Android). In function onCreateOptionsMenu I get the error I describe…
Sascuash
  • 3,661
  • 10
  • 46
  • 65
0
votes
1 answer

Add onCreateOptionsMenu items from a web service

I have to dynamically change the onCreateOptionsMenu items. I am fetching the items from a web service. But the problem is that the service is called in onCreate() and in an AsyncTask class so before the data from the service arrives…
Hussain Marvi
  • 455
  • 1
  • 5
  • 17