我想在一个变量中记录用户在子菜单中的选择,问题是永远不会调用 onOptionsMenuClosed 方法。
public class BrowserXActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public boolean onCreateOptionsMenu(Menu menu){
SubMenu subMenu2 = menu.addSubMenu("Scelta Lingua");
//subMenu2.setIcon(R.drawable.icon_manage);
subMenu2.add(2, Menu.NONE, Menu.NONE, "Italiano");
subMenu2.add(2, Menu.NONE, Menu.NONE, "Inglese");
subMenu2.setGroupCheckable(2, true, true);
return true;
}
public boolean onOptionsItemSelected(MenuItem item){
if(item.isCheckable()){
item.setChecked(false);
}else{
item.setChecked(true);
}
return true;
}
public void onOptionsMenuClosed(Menu menu){
Log.i("A", "enter");
// Log.i("A", "" + menu.getItem(0));
// Log.i("A", "" + menu.getItem(1));
}
}