This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with onCreateOptionsMenu

 
Grigoriy Gusarov
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all.

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

My code:
package com.gusarov.menu;

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

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}

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

}

@Override
public boolean onCreateOptionsMenu(Menu menu)
{
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.game_menu, menu);
return true;
}



Безымянный.png
[Thumbnail for Безымянный.png]
 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know what the IDE is doing, but you can see the method here:
http://developer.android.com/reference/android/app/Activity.html#onCreateOptionsMenu(android.view.Menu)

And it indicates it existed since API level 1, so no chance of having too old a version...
 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic