要获得自定义溢出菜单,我使用子菜单作为
@Override
public boolean onCreateOptionsMenu(Menu menu) {
//Create the search view
SearchView searchView = new SearchView(getSupportActionBar().getThemedContext());
mListView = getListView();
mListView.setTextFilterEnabled(true);
setupSearchView(searchView);
menu.add(0, 1, 1, "Export")
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS| MenuItem.SHOW_AS_ACTION_WITH_TEXT);
menu.add(0, 2, 2, "Import")
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
menu.add(0, 3, 3, null)
.setIcon(R.drawable.ic_action_overflow)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
SubMenu subMenu = menu.addSubMenu(0, 0, 2, null);
subMenu.add(0, 4, 4, "Search Message")
.setIcon(R.drawable.ic_search)
.setActionView(searchView)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
subMenu.add(0, 5, 5, "Settings")
.setIcon(R.drawable.ic_settings);
subMenu.add(0, 6, 6, "About")
.setIcon(R.drawable.ic_about);
MenuItem subMenuItem = subMenu.getItem();
subMenuItem.setIcon(R.drawable.ic_action_overflow);
subMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
return super.onCreateOptionsMenu(menu);
}
这让我的行动项目为
我唯一的问题是,在更宽的屏幕上,我也会获得默认溢出菜单以及我自己的自定义溢出菜单。如何隐藏默认溢出菜单?