为什么我从第21行获取错误“onCreateOptionsMenu(菜单菜单)”
包com.example.movieplayer;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.EditText;
import android.widget.Button;
import android.view.View;
import android.widget.Toast;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
private 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;
}
}
答案 0 :(得分:3)
onCreateOptions菜单在基类中指定。该方法具有公众的可见性。由于您要覆盖该方法,因此无法将其更改为私有。
这样:
@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;
}