我正在制作应用,我需要在主要活动中引用资源文件。路径是res / menu / main.xml,我该怎么做?这是源代码。
package com.example.bradenmyers.quikiflipi;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.PopupMenu;
import android.view.Menu;
import android.view.MenuInflater;
public class MainActivity extends AppCompatActivity {
private PopupMenu menuInflator;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R(This R is Red).layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflator().inflate(R(This R is also Red).menu.main, menu);
return super.onCreateOptionsMenu(menu);
}
private MenuInflater getMenuInflator() {
return null;
}
}