Questions tagged [oncreateoptionsmenu]
112 questions
205
votes
7 answers
onCreateOptionsMenu inside Fragments
I have placed setHasOptionsMenu(true) inside onCreateView, but I still can't call onCreateOptionsMenu inside fragments.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle…

Kevin
- 23,174
- 26
- 81
- 111
74
votes
12 answers
onCreateOptionsMenu is never called
I am having some trouble getting an options menu working in Android. I have built apps before, and they all worked fine, but now the menu just doesn't pop up.
The code:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
…

Bart Friederichs
- 33,050
- 15
- 95
- 195
54
votes
1 answer
What is the difference between onCreateOptionsMenu(Menu menu) and onPrepareOptionsMenu(Menu menu)?
Explain difference between onCreateOptionsMenu(Menu menu) and onPrepareOptionsMenu(Menu menu).

Jumpo
- 641
- 2
- 6
- 7
11
votes
5 answers
Implementing an option menu in Android Studio
How do I implement an option menu in my android application? I tried code from Android Developer but I get errors. Such as these: Element menu must be declared. Here is my code
10
votes
2 answers
Why does onCreateOptionsMenu run multiple times?
For some reason, my onCreateOptionsMenu and onPrepareOptionsMenu run twice (checked with a log input on the start of both methods). This happens for multiple fragments that I have, including some that are very basic (just inflating the menu, nothing…

Timmiej93
- 1,328
- 1
- 16
- 35
9
votes
5 answers
java.lang.illegalstateexception: a factory has already been set on this layoutinflater
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…

samvijay
- 197
- 5
- 14
7
votes
2 answers
call onCreateOptionsMenu in onPostCreate
I want to dynamically change the onCreateOptionsMenu items. I have rectified my problem and the only solution is to call onCreateOptionsMenu in onPostCreate but i don't know how to call it.
I have already tried my solutions non works. Is it even…

Hussain Marvi
- 455
- 1
- 5
- 17
7
votes
3 answers
What is the call order of oncreateoptionsmenu() in the android activity lifecycle?
Is onCreateOptionsMenu() of action bar called before or after the onStart() of activity?

Dhruva Bharadwaj
- 101
- 1
- 7
7
votes
1 answer
onCreate, onCreateOptionsMenu, onResume, what is the order of execution?
I'm sorry if this question was asked before...
Well anyway as what the title asked, when does onCreateOptionsMenu executed? before or after onResume?
In my app,
when the activity first run/opened the order will be onCreate --> onResume -->…

CodingBird
- 705
- 2
- 11
- 22
6
votes
0 answers
Android : onCreateOptionsMenu called too late
In my Activity I created a MenuItem that performs a clockwise animation in ActionBar when some data is loading. When loadData() is called the MenuItem has start the clockwise animation.
This works great, but when I first call loadData() inside…

TheModularMind
- 2,024
- 2
- 22
- 36
5
votes
3 answers
Why does the Android onCreateOptionsMenu method return super.onCreateOptionsMenu?
As I'm new to Android programming, I've encountered another little thing that I don't understand. Why does the onCreateOptionsMenu method below return super.onCreateOptionsMenu instead of just calling super.onCreateOptionsMenu (as it's done in the…

PenguinCake
- 317
- 2
- 4
- 9
5
votes
3 answers
onCreateOptionsMenu is not called
I have simple application.
Here is MyActivity.java
public class MyActivity extends Activity {
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
…

vetalitet
- 703
- 2
- 10
- 25
5
votes
1 answer
Getting Switch instance inside ActionBar
I managed to put a Switch inside the action bar (as in the Wi-Fi settings).
I put the following mainmenu.xml file inside the /menu folder:
4
votes
1 answer
Nested Fragments lose calls to onCreateOptionsMenu after screen rotation
I implemented an Activity (A) that displays only one fragment (PF) with getSupportFragmentManager().
Fragment (PF) has one ViewPager to display 2 Fragments (F1 and F2).
ViewPager uses FragmentPagerAdapter with getChildFragmentManager().
Relative…

user2196895
- 41
- 4
4
votes
3 answers
Searchable Configuaration Returning Null For the SearchView
I have created a search interface but I can't seem to connect the SearchView in the ActionBar to my searchable configuration file. When I try to retreive it in my onCreateOptionsMenu method SearchManager.getSearchableInfo(getComponentName() returns…

Tanuj Nayak
- 607
- 1
- 8
- 22