@Override public boolean onCreateOptionsMenu( final Menu pMenu, final int pMenuIdOffset, final MapView pMapView) { final SubMenu mapMenu = pMenu .addSubMenu(0, MENU_MAP_MODE + pMenuIdOffset, Menu.NONE, R.string.map_mode) .setIcon(R.drawable.ic_menu_mapmode); for (int a = 0; a < TileSourceFactory.getTileSources().size(); a++) { final ITileSource tileSource = TileSourceFactory.getTileSources().get(a); mapMenu.add( MENU_MAP_MODE + pMenuIdOffset, MENU_TILE_SOURCE_STARTING_ID + a + pMenuIdOffset, Menu.NONE, tileSource.name()); } mapMenu.setGroupCheckable(MENU_MAP_MODE + pMenuIdOffset, true, true); if (ctx != null) { final String title = ctx.getString( pMapView.useDataConnection() ? R.string.set_mode_offline : R.string.set_mode_online); final Drawable icon = ctx.getResources().getDrawable(R.drawable.ic_menu_offline); pMenu.add(0, MENU_OFFLINE + pMenuIdOffset, Menu.NONE, title).setIcon(icon); } return true; }
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); hackForSubmenus = menu; if (progress != null && (actionBarCompat == null || actionBarCompat.hasMenuButton())) return false; // not safe/useful until game is loaded MenuItem item; item = menu.findItem(R.id.solve); item.setEnabled(solveEnabled); if (actionBarCompat != null) item.setVisible(solveEnabled); MenuItem undoItem = menu.findItem(R.id.undo), redoItem = menu.findItem(R.id.redo); undoItem.setEnabled(undoEnabled); redoItem.setEnabled(redoEnabled); undoItem.setIcon( undoEnabled ? R.drawable.sym_keyboard_undo : R.drawable.sym_keyboard_undo_disabled); redoItem.setIcon( redoEnabled ? R.drawable.sym_keyboard_redo : R.drawable.sym_keyboard_redo_disabled); item = menu.findItem(R.id.type); item.setEnabled(!gameTypes.isEmpty() || customVisible); if (actionBarCompat != null) item.setVisible(item.isEnabled()); typeMenu = item.getSubMenu(); for (Integer i : gameTypes.keySet()) { if (menu.findItem(i) == null) typeMenu.add(R.id.typeGroup, i, Menu.NONE, gameTypes.get(i)); } MenuItem customItem = menu.findItem(R.id.custom); customItem.setVisible(customVisible); typeMenu.setGroupCheckable(R.id.typeGroup, true, true); if (currentType < 0) customItem.setChecked(true); else if (currentType < gameTypes.size()) menu.findItem((Integer) gameTypes.keySet().toArray()[currentType]).setChecked(true); menu.findItem(R.id.thisgame) .setTitle( MessageFormat.format(getString(R.string.help_on_game), new Object[] {this.getTitle()})); return true; }
public static void addMapTypeMenu(IGxMapView mapView, Menu menu) { SubMenu subMenu = menu.addSubMenu(Menu.NONE, R.id.map_mode, 0, R.string.GXM_SelectMapType); MenuItem itemStandard = addMapTypeMenuOption( mapView, subMenu, GxMapViewDefinition.MAP_TYPE_STANDARD, MENU_TYPE_STANDARD, R.string.GXM_Standard); MenuItem itemSatellite = addMapTypeMenuOption( mapView, subMenu, GxMapViewDefinition.MAP_TYPE_SATELLITE, MENU_TYPE_SATELLITE, R.string.GXM_Satellite); MenuItem itemHybrid = addMapTypeMenuOption( mapView, subMenu, GxMapViewDefinition.MAP_TYPE_HYBRID, MENU_TYPE_HYBRID, R.string.GXM_Hybrid); subMenu.setGroupCheckable(GROUP_MAP_TYPE, true, true); String currentMapType = mapView.getMapType(); if (currentMapType.equalsIgnoreCase(GxMapViewDefinition.MAP_TYPE_SATELLITE)) itemSatellite.setChecked(true); else if (currentMapType.equalsIgnoreCase(GxMapViewDefinition.MAP_TYPE_HYBRID)) itemHybrid.setChecked(true); else itemStandard.setChecked(true); }
/** * Sets up the options menu when the menu button is push, dynamic population of the station select * menu */ public boolean onPrepareOptionsMenu(Menu menu) { menu.clear(); boolean result = super.onCreateOptionsMenu(menu); SubMenu subMenu = menu.addSubMenu(BASE_OPTION_MENU, FM_BAND, Menu.NONE, R.string.band_select); subMenu.setIcon(android.R.drawable.ic_menu_mapmode); // Populate the band selection menu subMenu.add(BAND_SELECTION_MENU, BAND_US, Menu.NONE, R.string.band_us); subMenu.add(BAND_SELECTION_MENU, BAND_EU, Menu.NONE, R.string.band_eu); subMenu.add(BAND_SELECTION_MENU, BAND_CHINA, Menu.NONE, R.string.band_ch); subMenu.add(BAND_SELECTION_MENU, BAND_JAPAN, Menu.NONE, R.string.band_ja); subMenu.setGroupCheckable(BAND_SELECTION_MENU, true, true); subMenu.getItem(mSelectedBand).setChecked(true); return result; }
public static void addMapviewMenuItems(final Menu menu) { final SubMenu parentMenu = menu.findItem(R.id.menu_select_mapview).getSubMenu(); final int currentSource = Settings.getMapSource().getNumericalId(); for (int i = 0; i < mapSources.size(); i++) { final MapSource mapSource = mapSources.get(i); final int id = mapSource.getNumericalId(); parentMenu .add(R.id.menu_group_map_sources, id, i, mapSource.getName()) .setCheckable(true) .setChecked(id == currentSource); } parentMenu.setGroupCheckable(R.id.menu_group_map_sources, true, true); }
public boolean bindNativeOverflow( android.view.Menu menu, android.view.MenuItem.OnMenuItemClickListener listener, HashMap<android.view.MenuItem, MenuItemImpl> map) { final List<MenuItemImpl> nonActionItems = getNonActionItems(); if (nonActionItems == null || nonActionItems.size() == 0) { return false; } boolean visible = false; menu.clear(); for (MenuItemImpl nonActionItem : nonActionItems) { if (!nonActionItem.isVisible()) { continue; } visible = true; android.view.MenuItem nativeItem; if (nonActionItem.hasSubMenu()) { android.view.SubMenu nativeSub = menu.addSubMenu( nonActionItem.getGroupId(), nonActionItem.getItemId(), nonActionItem.getOrder(), nonActionItem.getTitle()); SubMenuBuilder subMenu = (SubMenuBuilder) nonActionItem.getSubMenu(); for (MenuItemImpl subItem : subMenu.getVisibleItems()) { android.view.MenuItem nativeSubItem = nativeSub.add( subItem.getGroupId(), subItem.getItemId(), subItem.getOrder(), subItem.getTitle()); nativeSubItem.setIcon(subItem.getIcon()); nativeSubItem.setOnMenuItemClickListener(listener); nativeSubItem.setEnabled(subItem.isEnabled()); nativeSubItem.setIntent(subItem.getIntent()); nativeSubItem.setNumericShortcut(subItem.getNumericShortcut()); nativeSubItem.setAlphabeticShortcut(subItem.getAlphabeticShortcut()); nativeSubItem.setTitleCondensed(subItem.getTitleCondensed()); nativeSubItem.setCheckable(subItem.isCheckable()); nativeSubItem.setChecked(subItem.isChecked()); if (subItem.isExclusiveCheckable()) { nativeSub.setGroupCheckable(subItem.getGroupId(), true, true); } map.put(nativeSubItem, subItem); } nativeItem = nativeSub.getItem(); } else { nativeItem = menu.add( nonActionItem.getGroupId(), nonActionItem.getItemId(), nonActionItem.getOrder(), nonActionItem.getTitle()); } nativeItem.setIcon(nonActionItem.getIcon()); nativeItem.setOnMenuItemClickListener(listener); nativeItem.setEnabled(nonActionItem.isEnabled()); nativeItem.setIntent(nonActionItem.getIntent()); nativeItem.setNumericShortcut(nonActionItem.getNumericShortcut()); nativeItem.setAlphabeticShortcut(nonActionItem.getAlphabeticShortcut()); nativeItem.setTitleCondensed(nonActionItem.getTitleCondensed()); nativeItem.setCheckable(nonActionItem.isCheckable()); nativeItem.setChecked(nonActionItem.isChecked()); if (nonActionItem.isExclusiveCheckable()) { menu.setGroupCheckable(nonActionItem.getGroupId(), true, true); } map.put(nativeItem, nonActionItem); } return visible; }