菜单未显示在我的 emulator.menu 代码在 home.java 类中实现,inflator 使用菜单但未在 emulator 上显示。
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.home);
}
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater Inflater = getMenuInflater();
Inflater.inflate(R.layout.menu, menu);
return(super.onCreateOptionsMenu(menu));
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.logout) {
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.remove("logged");
editor.commit();
finish();
}
return super.onOptionsItemSelected(item);
}
}