菜单/activity_main.xml:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menu_settings"
android:title="@string/menu_settings"
android:showAsAction="never" />
<item android:id="@+id/menu_save_log"
android:title="@string/menu_save_log"
android:showAsAction="never" />
</menu>
MainActivity.java:
//@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_settings: // OK
break;
case R.id.menu_save_log: // menu_save_log cannot be resolved or is not a field
break;
}
return true;
}
为什么无法识别 menu_save_log?
附加信息。R.java:
public static final class menu {
public static final int activity_main=0x7f070000;
}
R.java 未更新。为什么?