Reputation: 11
i want to make maps. when i will try for first i have problem. this is my problem.
this my code
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
in this code, i have problem
getMenuInflater().inflate(R.menu.main, menu);
the comment is main cannot be resolved or is not a field
Upvotes: 1
Views: 14477
Reputation: 311
I faced same issue Just check your import for R. In my case it was.
import android.R;
Change it to
import your.application.packagename.R;
Upvotes: 0
Reputation: 50
You should have a menu.xml file in your res/menu folder (if you don't have any, make it), with a content like this:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_settings"
android:title="YOUR_MENU_ITEM"
app:showAsAction="never"/>
</menu>
Upvotes: 1