File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Android and the fly likes Problem with onCreateOptionsMenu Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "Problem with onCreateOptionsMenu" Watch "Problem with onCreateOptionsMenu" New topic

Problem with onCreateOptionsMenu

Grigoriy Gusarov

Joined: Jan 10, 2013
Posts: 1
Hello all.

I need to ovveride method onCreateOptionmenu, but i can`t find it in "override/implement methods".

My code:

import android.os.Bundle;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Menu;
import android.view.View;

public class MainActivity extends Activity {

protected void onCreate(Bundle savedInstanceState) {

public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(, menu);
return true;


public boolean onCreateOptionsMenu(Menu menu)
MenuInflater inflater = getMenuInflater();
inflater.inflate(, menu);
return true;

[Thumbnail for Безымянный.png]

Steve Luke

Joined: Jan 28, 2003
Posts: 4181

I don't know what the IDE is doing, but you can see the method here:

And it indicates it existed since API level 1, so no chance of having too old a version...

Steve Luke

Joined: Jan 28, 2003
Posts: 4181

Just played with Eclipse: looks like the IDE removes the method from the list of methods to insert/override if you have already inserted/overriden it. So since your Activity already has the boolean onCreateOptionsMenu(Menu) method, that method is removed from the list.
I agree. Here's the link:
subject: Problem with onCreateOptionsMenu
It's not a secret anymore!