List of usage examples for android.view Menu NONE
int NONE
To view the source code for android.view Menu NONE.
Click Source Link
From source file:org.mozilla.gecko.BrowserApp.java
/** * Add the provided item to the provided menu, which should be * the root (mMenu).//from ww w . ja v a 2 s .com */ private void addAddonMenuItemToMenu(final Menu menu, final MenuItemInfo info) { info.added = true; final Menu destination; if (info.parent == 0) { destination = menu; } else if (info.parent == GECKO_TOOLS_MENU) { // The tools menu only exists in our -v11 resources. if (Versions.feature11Plus) { final MenuItem tools = menu.findItem(R.id.tools); destination = tools != null ? tools.getSubMenu() : menu; } else { destination = menu; } } else { final MenuItem parent = menu.findItem(info.parent); if (parent == null) { return; } Menu parentMenu = findParentMenu(menu, parent); if (!parent.hasSubMenu()) { parentMenu.removeItem(parent.getItemId()); destination = parentMenu.addSubMenu(Menu.NONE, parent.getItemId(), Menu.NONE, parent.getTitle()); if (parent.getIcon() != null) { ((SubMenu) destination).getItem().setIcon(parent.getIcon()); } } else { destination = parent.getSubMenu(); } } final MenuItem item = destination.add(Menu.NONE, info.id, Menu.NONE, info.label); item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Menu:Clicked", Integer.toString(info.id - ADDON_MENU_OFFSET))); return true; } }); if (info.icon == null) { item.setIcon(R.drawable.ic_menu_addons_filler); } else { final int id = info.id; BitmapUtils.getDrawable(this, info.icon, new BitmapUtils.BitmapLoader() { @Override public void onBitmapFound(Drawable d) { // TODO: why do we re-find the item? final MenuItem item = destination.findItem(id); if (item == null) { return; } if (d == null) { item.setIcon(R.drawable.ic_menu_addons_filler); return; } item.setIcon(d); } }); } item.setCheckable(info.checkable); item.setChecked(info.checked); item.setEnabled(info.enabled); item.setVisible(info.visible); }