Reputation: 21
I'm learning how to make android app, and below is the code I'm using to create a main menu. The problem is that it keeps saying "mainmenu cannot be resolved or is not a field."
package chapter.seven;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuInflater;
public class UserInterface extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user_interface);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.mainmenu, menu);
return true;
}
}
Upvotes: 0
Views: 129
Reputation: 16043
In addition to what Paul said, import the application resource file if the class is not in the same package as the app's declared package:
import chapter.seven.R;
Upvotes: 0
Reputation: 5223
mainmenu
XML Resource file which contains a proper menu definition.Upvotes: 1