public boolean onCreateOptionsMenu(Menu menu) { menu.add(0, START_LIVE_DATA, 0, "Start Live Data"); menu.add(0, COMMAND_ACTIVITY, 0, "Run Command"); menu.add(0, STOP_LIVE_DATA, 0, "Stop"); menu.add(0, SETTINGS, 0, "Settings"); return true; }
public boolean onPrepareOptionsMenu(Menu menu) { MenuItem startItem = menu.findItem(START_LIVE_DATA); MenuItem stopItem = menu.findItem(STOP_LIVE_DATA); MenuItem settingsItem = menu.findItem(SETTINGS); MenuItem commandItem = menu.findItem(COMMAND_ACTIVITY); // validate if preRequisites are satisfied. if (preRequisites) { if (mServiceConnection.isRunning()) { startItem.setEnabled(false); stopItem.setEnabled(true); settingsItem.setEnabled(false); commandItem.setEnabled(false); } else { stopItem.setEnabled(false); startItem.setEnabled(true); settingsItem.setEnabled(true); commandItem.setEnabled(false); } } else { startItem.setEnabled(false); stopItem.setEnabled(false); settingsItem.setEnabled(false); commandItem.setEnabled(false); } return true; }
/** * Shows "call via" menu allowing user to selected from multiple providers. * * @param context the android context * @param v the View that will contain the popup menu. * @param destination target callee name. */ private static void showCallViaMenu(final Context context, View v, final String destination) { PopupMenu popup = new PopupMenu(context, v); Menu menu = popup.getMenu(); Iterator<ProtocolProviderService> registeredProviders = AccountUtils.getRegisteredProviders().iterator(); while (registeredProviders.hasNext()) { final ProtocolProviderService provider = registeredProviders.next(); String accountAddress = provider.getAccountID().getAccountAddress(); MenuItem menuItem = menu.add(Menu.NONE, Menu.NONE, Menu.NONE, accountAddress); menuItem.setOnMenuItemClickListener( new MenuItem.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { createCall(context, destination, provider); return false; } }); } popup.show(); }
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater menuInflater = getMenuInflater(); menuInflater.inflate(R.menu.main_menu, menu); menu.add("添加").setIcon(R.drawable.menu_add); menu.add("帮助").setIcon(R.drawable.menu_help); menu.add("联系").setIcon(R.drawable.menu_contact); return super.onCreateOptionsMenu( menu); // To change body of overridden methods use File | Settings | File Templates. }
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.gatt_services, menu); if (mConnected) { menu.findItem(R.id.menu_connect).setVisible(false); menu.findItem(R.id.menu_disconnect).setVisible(true); } else { menu.findItem(R.id.menu_connect).setVisible(true); menu.findItem(R.id.menu_disconnect).setVisible(false); } return true; }
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); if (weChatUtils.getIWXAPI().isWXAppInstalled()) { inflater.inflate(R.menu.main_wechat, menu); } else { inflater.inflate(R.menu.main, menu); } MenuItem shareItem = menu.findItem(R.id.action_share); android.support.v4.view.ActionProvider actionProvider = MenuItemCompat.getActionProvider(shareItem); if (null != actionProvider && actionProvider instanceof ShareActionProvider) { mShareActionProvider.setShareHistoryFileName( ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME); // mShareActionProvider.setShareIntent(Utils.getShareRawIntent(this)); mShareActionProvider.setOnShareTargetSelectedListener( new ShareActionProvider.OnShareTargetSelectedListener() { @Override public boolean onShareTargetSelected( ShareActionProvider shareActionProvider, Intent intent) { updateShareIntent(); return false; } }); updateShareIntent(); for (int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); if (item.getItemId() == R.id.action_share) { View itemChooser = MenuItemCompat.getActionView(item); if (itemChooser != null) { itemChooser.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { EFLogger.i(TAG, "onClick"); ScreenshotUtils.shotBitmap(MainActivity.this, shareFileName); } }); } } } } return super.onCreateOptionsMenu(menu); }
@Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { menu.add(0, 0, 0, getString(R.string.hand_in_label)) .setIcon(R.drawable.icon_retreive) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); return true; }
/* Called whenever we call invalidateOptionsMenu() */ @Override public boolean onPrepareOptionsMenu(Menu menu) { // If the nav drawer is open, hide action items related to the content view boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList); menu.findItem(R.id.action_search).setVisible(!drawerOpen); // search return super.onPrepareOptionsMenu(menu); }
/** {@inheritDoc} */ private void updateChecked() { if (menu == null) return; ((CompoundButton) menu.findItem(R.id.toggleView).getActionView().findViewById(android.R.id.toggle)) .setChecked(model.isChecked()); }
@Override public boolean onCreateOptionsMenu(Menu menu) { Log.d(TAG, "Create menu options"); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.loader_menu, menu); menu.findItem(R.id.loader_menu_refresh_map_list).setVisible(mLoader < 0); return true; }
@Override public boolean onPrepareOptionsMenu(Menu m) { super.onPrepareOptionsMenu(m); boolean showMenu = false; if (activeView == viewCaptureNote || activeView == viewTagList || activeView == viewNoteGallery) { m.findItem(R.id.menu_tag_note).setVisible(false); m.findItem(R.id.menu_delete_note).setVisible(false); showMenu = true; } else if (activeView == viewNote) { m.findItem(R.id.menu_tag_note).setVisible(true); m.findItem(R.id.menu_delete_note).setVisible(true); showMenu = true; } return showMenu; }
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); final MenuItem item = menu.add(0, 1, Menu.NONE, myResource.getResource("menu").getResource("search").getValue()); item.setOnMenuItemClickListener(this); item.setIcon(R.drawable.ic_menu_search); return true; }
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); menu.add(0, SAVE_ID, 0, R.string.menu_save) .setIcon(R.drawable.save) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); menu.add(0, LOCK_ID, 0, R.string.menu_item_lock) .setIcon(R.drawable.lock) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); menu.add(0, DELETE_ID, 0, R.string.menu_delete) .setIcon(R.drawable.delete) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); menu.add(0, SHARE_ID, 0, R.string.menu_share) .setIcon(R.drawable.share) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); menu.add(0, SMALLER_ID, 0, R.string.menu_smaller) .setIcon(R.drawable.smaller) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); menu.add(0, BIGGER_ID, 0, R.string.menu_bigger) .setIcon(R.drawable.bigger) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); return true; }
@Override public boolean onCreateOptionsMenu(Menu menu) { isGreenStyle = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("style", true); getMenuInflater().inflate(isGreenStyle ? R.menu.menu_new : R.menu.ivt_menu_new, menu); if (!Globals.isPlaying) { MenuItem item = menu.findItem(R.id.action_current_play); item.setVisible(false); // MenuItem item_divider = menu.findItem(R.id.action_divider); // item_divider.setVisible(false); this.invalidateOptionsMenu(); } SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setOnSearchClickListener( new OnClickListener() { @Override public void onClick(View v) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext.getApplicationContext()); Boolean isImmer = prefs.getBoolean(mContext.getString(R.string.searchview_checkbox_key), true); if (!isImmer) { // Toast.makeText(mContext, "not isImmer", // Toast.LENGTH_LONG).show(); } else { SearchViewDialog dialog = new SearchViewDialog(mContext); dialog.show(); // Toast.makeText(mContext, "isImmer", // Toast.LENGTH_LONG).show(); } } }); return true; }
/** {@inheritDoc} */ @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.actionbar_toggle_menu, menu); // Binds the button CompoundButton cBox = (CompoundButton) menu.findItem(R.id.toggleView).getActionView().findViewById(android.R.id.toggle); cBox.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton cb, boolean checked) { model.setChecked(checked); } }); // Set label text ((TextView) menu.findItem(R.id.toggleView).getActionView().findViewById(android.R.id.text1)) .setText(getArguments().getString(ARG_LABEL_TEXT)); this.menu = menu; updateChecked(); }
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); MenuItem searchViewMenuItem = menu.findItem(R.id.action_search); search = (SearchView) searchViewMenuItem.getActionView(); search.setOnQueryTextListener( new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { return false; } @Override public boolean onQueryTextChange(String newText) { if (adapter != null) { Filter filter = adapter.getFilter(); filter.filter(newText); } return true; } }); }
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); menu.add(0, CONFIG_ID, 0, R.string.config); return true; }
@Override public boolean onPrepareOptionsMenu(Menu menu) { Log.d(TAG, "Prepare menu options"); menu.findItem(R.id.loader_menu_refresh_map_list).setVisible(mLoader < 0); return true; }