public boolean performItemAction(MenuItem item, int flags) { MenuItemImpl itemImpl = (MenuItemImpl) item; if (itemImpl == null || !itemImpl.isEnabled()) { return false; } boolean invoked = itemImpl.invoke(); if (itemImpl.hasCollapsibleActionView()) { invoked |= itemImpl.expandActionView(); if (invoked) close(true); } else if (item.hasSubMenu()) { close(false); final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu(); final ActionProvider provider = item.getActionProvider(); if (provider != null && provider.hasSubMenu()) { provider.onPrepareSubMenu(subMenu); } invoked |= dispatchSubMenuSelected(subMenu); if (!invoked) close(true); } else { if ((flags & FLAG_PERFORM_NO_CLOSE) == 0) { close(true); } } return invoked; }
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate your menu. getSupportMenuInflater().inflate(R.menu.share_action_provider, menu); // Set file with share history to the provider and set the share intent. MenuItem actionItem = menu.findItem(R.id.menu_item_share_action_provider_action_bar); ShareActionProvider actionProvider = (ShareActionProvider) actionItem.getActionProvider(); actionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME); // Note that you can set/change the intent any time, // say when the user has selected an image. actionProvider.setShareIntent(createShareIntent()); // XXX: For now, ShareActionProviders must be displayed on the action bar // Set file with share history to the provider and set the share intent. // MenuItem overflowItem = menu.findItem(R.id.menu_item_share_action_provider_overflow); // ShareActionProvider overflowProvider = // (ShareActionProvider) overflowItem.getActionProvider(); // overflowProvider.setShareHistoryFileName( // ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME); // Note that you can set/change the intent any time, // say when the user has selected an image. // overflowProvider.setShareIntent(createShareIntent()); return true; }
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.tropes_fragment_menu, menu); inflater.inflate(R.menu.index_fragment_menu, menu); MenuItem shareItem = menu.findItem(R.id.share_article); shareProvider = (ShareActionProvider) shareItem.getActionProvider(); }
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getSupportMenuInflater(); inflater.inflate(R.menu.showinfo_menu, menu); MenuItem shareItem = menu.findItem(R.id.menu_share); ShareActionProvider shareActionProvider = (ShareActionProvider) shareItem.getActionProvider(); shareActionProvider.setShareIntent(mShareIntentBuilder.getIntent()); return true; }
@Override public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) { inflater.inflate(R.menu.request_coins_fragment_options, menu); final MenuItem shareItem = menu.findItem(R.id.request_coins_options_share); shareActionProvider = (ShareActionProvider) shareItem.getActionProvider(); updateShareIntent(); if (!checkForLocalApp()) menu.removeItem(2); // The "Request from local" menu entry. super.onCreateOptionsMenu(menu, inflater); }