目前,我的操作栏夏洛克图标中有此代码:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// OverFlow PLUS icon ABS
SubMenu submenu1 = menu.addSubMenu("");
submenu1.setIcon(R.drawable.ic_action_plus0_transparent);
submenu1.add(1, 0, 1, "New Cat");
submenu1.add(1, 1, 2, "New Subcat");
submenu1.add(1, 2, 3, "Other");
submenu1.getItem().setShowAsAction(
MenuItem.SHOW_AS_ACTION_ALWAYS
| MenuItem.SHOW_AS_ACTION_WITH_TEXT);
// OverFlow FILTER icon ABS
SubMenu submenu2 = menu.addSubMenu("");
submenu2.setIcon(R.drawable.ic_action_filter0_transparent);
submenu2.add(1, 0, 1, "Filter 1");
submenu2.add(1, 1, 2, "Filter 2");
submenu2.add(1, 2, 3, "Filter 3");
submenu2.getItem().setShowAsAction(
MenuItem.SHOW_AS_ACTION_ALWAYS
| MenuItem.SHOW_AS_ACTION_WITH_TEXT);
// OverFlow INFO icon ABS
SubMenu submenu3 = menu.addSubMenu("");
submenu3.setIcon(R.drawable.ic_action_info0_transparent);
submenu3.add(1, 0, 1, "Info A");
submenu3.add(1, 1, 2, "Info B");
submenu3.add(1, 2, 3, "Info C");
submenu3.getItem().setShowAsAction(
MenuItem.SHOW_AS_ACTION_ALWAYS
| MenuItem.SHOW_AS_ACTION_WITH_TEXT);
// OverFlow MENU icon ABS
SubMenu submenu4 = menu.addSubMenu("");
submenu4.setIcon(R.drawable.ic_action_menu0_transparent);
submenu4.add(1, 0, 1, "Primeiro");
submenu4.add(1, 1, 2, "Segundo");
submenu4.add(1, 2, 3, "Terceiro");
submenu4.getItem().setShowAsAction(
MenuItem.SHOW_AS_ACTION_ALWAYS
| MenuItem.SHOW_AS_ACTION_WITH_TEXT);
// end overflow menu
return true;
}
我的意图是让第一个图标 (submenu1.setIcon(R.drawable.ic_action_plus0_transparent) 和第二个图标 (submenu2.setIcon(R.drawable.ic_action_filter0_transparent) 成为将用户发送到其他活动而不是下拉菜单的单击按钮。我无法做到这一点,因为我看到的大多数示例都有下拉菜单内容作为其他 2 个可用图标。有人可以帮帮我吗?