我正在尝试制作OptionsMenu
,这是我的代码:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
return super.onCreateOptionsMenu(menu);
}
public boolean onOptionsItemSelect(MenuItem item){
switch (item.getItemId()){
case R.id.Guardar:
Toast.makeText(DrawFunny.this, "Guardar",Toast.LENGTH_LONG).show();
return true;
case R.id.Finish:
return true;
default:
return super.onOptionsItemSelected(item);
}
}
菜单:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
<group android:id="@+id/group1">
<item android:id="@+id/Guardar" android:title="Guardar"></item>
<item android:id="@+id/Finish" android:title="Terminar"></item>
</group>
</menu>
This menu is displayed on the screen but when items are selected, it does nothing.