Questions tagged [oncreateoptionsmenu]

106 questions
193
votes
6 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
  • 21,638
  • 25
  • 75
  • 108
68
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
  • 30,888
  • 13
  • 85
  • 169
52
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
  • 591
  • 2
  • 5
  • 7
11
votes
4 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
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…
8
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 -->…
7
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,158
  • 1
  • 11
  • 30
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…
HussainMarvi
  • 457
  • 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?
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
  • 1,963
  • 1
  • 19
  • 36
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
  • 653
  • 2
  • 10
  • 24
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
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
  • 297
  • 2
  • 4
  • 9
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…
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
  • 597
  • 1
  • 7
  • 22
1
2 3 4 5 6 7 8