这是我的代码,但它崩溃了:
public boolean onCreateOptionsMenu(Menu menu) {
SubMenu sub = menu.addSubMenu(0, 1, 1, "register");
sub.add(0, 3, 1, "register book");
sub.add(0, 4, 2, "register new book");
menu.add(0, 2, 2, "report");
return super.onCreateOptionsMenu(menu);
}
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()){
case 4:
Intent intent = new Intent(bookActivity.this, newbookActivity.class);
bookActivity.this.startActivity(intent);
break;
return super.onOptionsItemSelected(item);
}
}