List of usage examples for android.view MenuInflater inflate
public void inflate(@MenuRes int menuRes, Menu menu)
From source file:com.android.contacts.quickcontact.QuickContactActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { final MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.quickcontact, menu); return true;// w ww . j a va 2s.c om }
From source file:com.amaze.filemanager.activities.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater menuInflater = getMenuInflater(); menuInflater.inflate(R.menu.activity_extra, menu); return super.onCreateOptionsMenu(menu); }
From source file:com.amaze.carbonfilemanager.activities.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater menuInflater = getMenuInflater(); menuInflater.inflate(R.menu.activity_extra, menu); /*/*w ww . j a v a 2 s .c o m*/ SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(false); MenuItem search = menu.findItem(R.id.search); MenuItemCompat.setOnActionExpandListener(search, new MenuItemCompat.OnActionExpandListener() { @Override public boolean onMenuItemActionExpand(MenuItem item) { // Stretching the SearchView across width of the Toolbar toolbar.setContentInsetsRelative(0, 0); return true; } @Override public boolean onMenuItemActionCollapse(MenuItem item) { // Restoring toolbar.setContentInsetsRelative(TOOLBAR_START_INSET, 0); return true; } }); */ return super.onCreateOptionsMenu(menu); }
From source file:com.msopentech.applicationgateway.EnterpriseBrowserActivity.java
public void showSettingsPopup(View v) { try {/* w w w . ja v a 2s . c o m*/ PopupMenu popup = new PopupMenu(this, v); MenuInflater inflater = popup.getMenuInflater(); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.menu_connection: { showAgentsList(); return true; } case R.id.menu_sign_in_or_out: { if (mIsSigninRequired) { // Menu item in sign in mode. //TODO: showSignIn(null, true); return true; } // Clean up the session. mTraits.sessionID = null; mTraits.token = null; mTraits.agent = null; // Indicate the condition. mIsSigninRequired = true; //Remove all tabs except one. mCustomTabHost.resetTabs(); mUrlEditTextView.setText(""); mProgressBarView.setProgress(0); // Disable the reload button and set the right image for it. mReloadButtonView.setEnabled(false); mReloadButtonView.setImageResource(R.drawable.reload_button); mStatusButtonView.setImageResource(R.drawable.connection_red); // Since it's the user's intention to sign out, his // history must be dropped. PersistenceManager.dropContent(PersistenceManager.ContentType.HISTORY); return true; } // Removed from RELEASE version. Should be active for development ONLY. // case R.id.menu_advanced_router_settings: { // showAdvancedRouterSettings(null); // } default: { return false; } } } }); inflater.inflate(R.menu.settings_menu, popup.getMenu()); if (mIsSigninRequired) { MenuItem signItem = popup.getMenu().findItem(R.id.menu_sign_in_or_out); signItem.setTitle(getResources().getString(R.string.browser_menu_item_sign_in)); } // Assumes that agent always has a display name. If display name is not present agent is considered to be not connected. MenuItem agentItem = popup.getMenu().findItem(R.id.menu_connection); String status = getResources().getString(R.string.browser_menu_item_choose_connection_not_connected); if (mTraits != null && mTraits.agent != null && !TextUtils.isEmpty(mTraits.agent.getDisplayName())) { status = mTraits.agent.getDisplayName(); } Spannable span = new SpannableString( getResources().getString(R.string.browser_menu_item_choose_connection, status)); span.setSpan(new RelativeSizeSpan(0.8f), 18, span.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); span.setSpan(new ForegroundColorSpan(Color.GRAY), 18, span.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); agentItem.setTitle(span); popup.show(); } catch (final Exception e) { Utility.showAlertDialog(EnterpriseBrowserActivity.class.getSimpleName() + ".showSettingsPopup(): Failed. " + e.toString(), EnterpriseBrowserActivity.this); } }
From source file:com.android.mail.compose.ComposeActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { final boolean superCreated = super.onCreateOptionsMenu(menu); // Don't render any menu items when there are no accounts. if (mAccounts == null || mAccounts.length == 0) { return superCreated; }//from www. ja va 2s.c o m MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.compose_menu, menu); /* * Start save in the correct enabled state. * 1) If a user launches compose from within gmail, save is disabled * until they add something, at which point, save is enabled, auto save * on exit; if the user empties everything, save is disabled, exiting does not * auto-save * 2) if a user replies/ reply all/ forwards from within gmail, save is * disabled until they change something, at which point, save is * enabled, auto save on exit; if the user empties everything, save is * disabled, exiting does not auto-save. * 3) If a user launches compose from another application and something * gets populated (attachments, recipients, body, subject, etc), save is * enabled, auto save on exit; if the user empties everything, save is * disabled, exiting does not auto-save */ mSave = menu.findItem(R.id.save); String action = getIntent() != null ? getIntent().getAction() : null; enableSave(mInnerSavedState != null ? mInnerSavedState.getBoolean(EXTRA_SAVE_ENABLED) : (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action) || Intent.ACTION_SENDTO.equals(action) || isDraftDirty())); final MenuItem helpItem = menu.findItem(R.id.help_info_menu_item); final MenuItem sendFeedbackItem = menu.findItem(R.id.feedback_menu_item); final MenuItem attachFromServiceItem = menu.findItem(R.id.attach_from_service_stub1); if (helpItem != null) { helpItem.setVisible(mAccount != null && mAccount.supportsCapability(AccountCapabilities.HELP_CONTENT)); } if (sendFeedbackItem != null) { sendFeedbackItem .setVisible(mAccount != null && mAccount.supportsCapability(AccountCapabilities.SEND_FEEDBACK)); } if (attachFromServiceItem != null) { attachFromServiceItem.setVisible(shouldEnableAttachFromServiceMenu(mAccount)); } // Show attach picture on pre-K devices. menu.findItem(R.id.add_photo_attachment).setVisible(!Utils.isRunningKitkatOrLater()); return true; }
From source file:com.nest5.businessClient.Initialactivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { mMenu = menu;//from w w w.j a v a2s. c o m MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main_menu, menu); SharedPreferences defaultprefs = PreferenceManager.getDefaultSharedPreferences(mContext); boolean layouttables = defaultprefs.getBoolean("arrange_tables", false); if (layouttables) { MenuItem tables = mMenu.findItem(R.id.layouttables); if (!tables.isVisible()) { tables.setVisible(true); invalidateOptionsMenu(); } MenuItem mesas = mMenu.findItem(R.id.menu_show_tables); if (!mesas.isVisible()) { mesas.setVisible(true); invalidateOptionsMenu(); } } return true; }
From source file:com.rfo.basic.Run.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Called when the menu key is pressed. super.onCreateOptionsMenu(menu); if (!Settings.getConsoleMenu(this)) { return false; }//from w w w . j a v a 2 s . c om MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.run, menu); MenuItem item = menu.getItem(1); if (Basic.DoAutoRun) { // If APK or shortcut, menu action is "Exit", not "Editor" item.setTitle(getString(R.string.exit)); } item.setEnabled(false); return true; }