Skip to content Skip to sidebar Skip to footer

Runtimeexception With Android Optionsmenu

My application was running fine until i added the following code to add an options Menu to my main Activity: @Override public boolean onCreateOptionsMenu(Menu menu) { Menu

Solution 1:

Does the id searchbutton exist in main.xml?

You would get back a null pointer if the id couldn't be found in your layout. The compiler won't catch this if the id exists in another layout file.

Solution 2:

Deleting the class R.java and letting Eclipse regenerate it solved it!

I think for any reason R.java was confused about some of the ids.

Post a Comment for "Runtimeexception With Android Optionsmenu"