Problem with onCreateOptionsMenu

Quickly share your Android Code Snippets here...

Problem with onCreateOptionsMenu

Postby ramesh_bh » Wed Oct 20, 2010 6:48 am

HI,

I want to call onCretaeOptionsMenu in my code, i have implemented my code like this :

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.main);
}

@Override
public boolean onCreateOptionsMenu(Menu menu)
{
menu.add(0, 0, 0, "First");
menu.add(0, 1, 1, "Second");
return super.onCreateOptionsMenu(menu);
}


But onCreateOptionsMenu is not at all calling, Can anyone help me on this ?
ramesh_bh
Junior Developer
Junior Developer
 
Posts: 20
Joined: Thu Oct 07, 2010 4:58 am

Top

Re: Problem with onCreateOptionsMenu

Postby urbantrad » Sat Oct 23, 2010 4:45 pm

the method is only called the first time you press the menu button. make sure to press the button to trigger it.
PS: you can make your code snippets more readable using the code tags
Code: Select all
public void toString() {
   return "Doesn't this look nicer?";
}
urbantrad
Senior Developer
Senior Developer
 
Posts: 104
Joined: Thu Sep 09, 2010 10:19 pm

Top

Return to Code Snippets for Android

Who is online

Users browsing this forum: Google [Bot] and 7 guests