List of usage examples for android.view MenuItem SHOW_AS_ACTION_IF_ROOM
int SHOW_AS_ACTION_IF_ROOM
To view the source code for android.view MenuItem SHOW_AS_ACTION_IF_ROOM.
Click Source Link
From source file:net.potterpcs.recipebook.RecipeEditor.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.editormenu, menu); // Set up the action bar for devices that have it MenuItemCompat.setShowAsAction(menu.findItem(R.id.editormenusave), MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT); MenuItemCompat.setShowAsAction(menu.findItem(R.id.editormenuhelp), MenuItem.SHOW_AS_ACTION_IF_ROOM); return true;/* w ww. ja va 2 s . c om*/ }
From source file:org.alfresco.mobile.android.application.fragments.person.PersonProfileFragment.java
private void getMenu(Menu menu, int mode) { MenuItem mi = null;//from www. j av a2 s .c o m switch (mode) { case MODE_CALL: if (person.getTelephoneNumber() != null && !person.getTelephoneNumber().isEmpty()) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_TEL, Menu.FIRST + MenuActionItem.MENU_TEL, person.getTelephoneNumber()); mi.setIcon(R.drawable.ic_call); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } if (person.getMobileNumber() != null && !person.getMobileNumber().isEmpty()) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_MOBILE, Menu.FIRST + MenuActionItem.MENU_MOBILE, person.getMobileNumber()); mi.setIcon(R.drawable.ic_call); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } if (person.getCompany() != null && person.getCompany().getTelephoneNumber() != null && !person.getCompany().getTelephoneNumber().isEmpty()) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_COMPANY_TEL, Menu.FIRST + MenuActionItem.MENU_COMPANY_TEL, person.getCompany().getTelephoneNumber()); mi.setIcon(R.drawable.ic_call); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } break; case MODE_SKYPE: mi = menu.add(Menu.NONE, MenuActionItem.MENU_CHAT, Menu.FIRST + MenuActionItem.MENU_CHAT, R.string.start_chat); mi.setIcon(R.drawable.ic_im); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mi = menu.add(Menu.NONE, MenuActionItem.MENU_CALL, Menu.FIRST + MenuActionItem.MENU_CALL, R.string.start_call); mi.setIcon(R.drawable.ic_call); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mi = menu.add(Menu.NONE, MenuActionItem.MENU_VIDEOCALL, Menu.FIRST + MenuActionItem.MENU_VIDEOCALL, R.string.start_video_call); mi.setIcon(R.drawable.ic_videocall); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); break; case MODE_EMAIL: if (person.getEmail() != null && !person.getEmail().isEmpty()) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_EMAIL, Menu.FIRST + MenuActionItem.MENU_EMAIL, person.getEmail()); mi.setIcon(R.drawable.ic_send_mail); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } if (person.getCompany() != null && person.getCompany().getEmail() != null && !person.getCompany().getEmail().isEmpty()) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_COMPANY_EMAIL, Menu.FIRST + MenuActionItem.MENU_COMPANY_EMAIL, person.getCompany().getEmail()); mi.setIcon(R.drawable.ic_send_mail); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } break; default: break; } }
From source file:net.potterpcs.recipebook.RecipeFlipbook.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.flippermenu, menu); // Show items on the action bar if we have one MenuItemCompat.setShowAsAction(menu.findItem(R.id.switchtolist), MenuItem.SHOW_AS_ACTION_IF_ROOM); MenuItemCompat.setShowAsAction(menu.findItem(R.id.flipbookhelp), MenuItem.SHOW_AS_ACTION_IF_ROOM); return true;/*w w w . ja v a2s . co m*/ }
From source file:com.docd.purefm.ui.fragments.BrowserFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); final AbstractBrowserActivity activity = getBrowserActivity(); if (activity.shouldShowBrowserFragmentMenu()) { inflater.inflate(R.menu.browser, menu); // TODO it returns true even on devices that don't have the physical key. // Find a better method to detect search hardware button //if (KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_SEARCH)) { // menu.removeItem(R.id.menu_search); //}//from w w w . j a v a2 s .c o m final MenuItem content = menu.findItem(android.R.id.content); if (content == null) { throw new RuntimeException("Inflated menu item should contain android.R.id.content"); } final Settings settings = Settings.getInstance(activity); switch (settings.getListAppearance()) { case LIST: content.setIcon(ThemeUtils.getDrawableNonNull(activity, R.attr.ic_menu_view_as_grid)) .setTitle(R.string.menu_view_as_grid).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); break; case GRID: content.setIcon(ThemeUtils.getDrawableNonNull(activity, R.attr.ic_menu_view_as_list)) .setTitle(R.string.menu_view_as_list).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); break; default: throw new IllegalArgumentException("Unexpected ListAppearance:" + settings.getListAppearance()); } if (ClipBoard.isEmpty()) { menu.removeItem(android.R.id.paste); } } }
From source file:tkj.android.homecontrol.mythmote.MythMote.java
/** * Called to create the options menu once. *//* w w w . j a v a 2 s. c o m*/ @TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override public boolean onCreateOptionsMenu(Menu menu) { boolean result = super.onCreateOptionsMenu(menu); // create reconnect menu item MenuItem menuItem = menu.add(0, RECONNECT_ID, 0, R.string.reconnect_str) .setIcon(R.drawable.ic_menu_refresh); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); } // create settings menu item menuItem = menu.add(0, SETTINGS_ID, 0, R.string.settings_menu_str) .setIcon(android.R.drawable.ic_menu_preferences); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } // create keyboard input menu item menuItem = menu.add(0, KEYBOARD_INPUT_ID, 0, R.string.keyboard_input_str) .setIcon(R.drawable.ic_notification_ime_default); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } // create select location menu item menuItem = menu.add(0, SELECTLOCATION_ID, 0, R.string.selected_location_str) .setIcon(R.drawable.ic_menu_home); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } //create wake on lan menu item menuItem = menu.add(0, SENDWOL_ID, 0, R.string.send_wol_str).setIcon(R.drawable.ic_menu_sun); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } //menu.add(0, SENDWOL_RE_ID, 0, R.string.send_wol_re_str); //menu.add(0, SENDWOL_PJ_ID, 0, R.string.send_wol_pj_str); //add donate button if enabled if (sShowDonateMenuItem) { } // return results return result; }
From source file:com.money.manager.ex.account.AccountTransactionListFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); //force show add transaction MenuItem itemAddTransaction = menu.findItem(R.id.menu_add_transaction_account); if (itemAddTransaction != null) itemAddTransaction.setVisible(true); //manage dual panel if (getActivity() != null && getActivity() instanceof MainActivity) { MainActivity activity = (MainActivity) getActivity(); if (!activity.isDualPanel()) { //hide sync toolbar MenuItem itemSync = menu.findItem(R.id.menu_sync); if (itemSync != null) itemSync.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); // hide menu open database MenuItem itemOpenDatabase = menu.findItem(R.id.menu_open_database); if (itemOpenDatabase != null) { //itemOpenDatabase.setVisible(isShownOpenDatabaseItemMenu()); itemOpenDatabase.setShowAsAction( !itemSync.isVisible() ? MenuItem.SHOW_AS_ACTION_ALWAYS : MenuItem.SHOW_AS_ACTION_NEVER); }//from w ww . ja v a 2s. co m //hide dash board MenuItem itemDashboard = menu.findItem(R.id.menu_dashboard); if (itemDashboard != null) itemDashboard.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } } selectCurrentPeriod(menu); selectCurrentStatus(menu); }
From source file:org.deviceconnect.android.deviceplugin.theta.fragment.ThetaGalleryFragment.java
@Override public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) { menu.clear();//from w ww .j a v a2 s.c o m // Add Menu Button mUpdateItem = menu.add(R.string.theta_update); if (mDevice != null) { mUpdateItem.setVisible(true); } else { mUpdateItem.setVisible(false); } mUpdateItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mUpdateItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(final MenuItem item) { if (item.getTitle().equals(mUpdateItem.getTitle())) { ShootingModeGetTask mode = new ShootingModeGetTask(); mDownloadTask = new DownloadThetaDataTask(); mDownloadTask.execute(mode); } return true; } }); }
From source file:website.openeng.anki.Reviewer.java
@SuppressLint("NewApi") @Override// ww w. j a v a2 s . c om public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.reviewer, menu); Resources res = getResources(); if (mCurrentCard != null && mCurrentCard.note().hasTag("marked")) { menu.findItem(R.id.action_mark_card).setTitle(R.string.menu_unmark_note) .setIcon(R.drawable.ic_star_white_24dp); } else { menu.findItem(R.id.action_mark_card).setTitle(R.string.menu_mark_note) .setIcon(R.drawable.ic_star_outline_white_24dp); } if (colIsOpen() && getCol().undoAvailable()) { menu.findItem(R.id.action_undo).setEnabled(true).getIcon().setAlpha(Themes.ALPHA_ICON_ENABLED_LIGHT); } else { menu.findItem(R.id.action_undo).setEnabled(false).getIcon().setAlpha(Themes.ALPHA_ICON_DISABLED_LIGHT); } if (mPrefWhiteboard) { // Don't force showing mark icon when whiteboard enabled // TODO: allow user to customize which icons are force-shown MenuItemCompat.setShowAsAction(menu.findItem(R.id.action_mark_card), MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); // Check if we can forceably squeeze in 3 items into the action bar, if not hide "show whiteboard" if (CompatHelper.getSdkVersion() >= 14 && !ViewConfiguration.get(this).hasPermanentMenuKey()) { // Android 4.x device with overflow menu in the action bar and small screen can't // support forcing 2 extra items into the action bar Display display = getWindowManager().getDefaultDisplay(); DisplayMetrics outMetrics = new DisplayMetrics(); display.getMetrics(outMetrics); float density = getResources().getDisplayMetrics().density; float dpWidth = outMetrics.widthPixels / density; if (dpWidth < 360) { menu.findItem(R.id.action_hide_whiteboard).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } } // Configure the whiteboard related items in the action bar menu.findItem(R.id.action_enable_whiteboard).setTitle(R.string.disable_whiteboard); menu.findItem(R.id.action_hide_whiteboard).setVisible(true); menu.findItem(R.id.action_clear_whiteboard).setVisible(true); Drawable whiteboardIcon = getResources().getDrawable(R.drawable.ic_gesture_white_24dp); if (mShowWhiteboard) { whiteboardIcon.setAlpha(255); menu.findItem(R.id.action_hide_whiteboard).setIcon(whiteboardIcon); menu.findItem(R.id.action_hide_whiteboard).setTitle(R.string.hide_whiteboard); } else { whiteboardIcon.setAlpha(77); menu.findItem(R.id.action_hide_whiteboard).setIcon(whiteboardIcon); menu.findItem(R.id.action_hide_whiteboard).setTitle(R.string.show_whiteboard); } } else { menu.findItem(R.id.action_enable_whiteboard).setTitle(R.string.enable_whiteboard); } if (!CompatHelper.isHoneycomb() && !mDisableClipboard) { menu.findItem(R.id.action_search_dictionary).setVisible(true) .setEnabled(!(mPrefWhiteboard && mShowWhiteboard)) .setTitle(clipboardHasText() ? Lookup.getSearchStringTitle() : res.getString(R.string.menu_select)); } return super.onCreateOptionsMenu(menu); }
From source file:com.guipenedo.pokeradar.activities.MapsActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuItem settings = menu.add(0, 0, 0, R.string.settings).setIcon(R.drawable.cog); settings.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override/*from w w w. j av a 2s.c o m*/ public boolean onMenuItemClick(MenuItem menuItem) { Intent i = new Intent(getBaseContext(), MainSettingsActivity.class); startActivity(i); return true; } }); MenuItem info = menu.add(0, 0, 0, R.string.about).setIcon(R.drawable.info_circle); info.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { Intent i = new Intent(getBaseContext(), AboutActivity.class); startActivity(i); return true; } }); info.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); settings.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); MenuItem logOut = menu.add(0, 0, 0, R.string.log_out).setIcon(R.drawable.sign_out); logOut.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { Utils.relog(MapsActivity.this); return true; } }); logOut.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); return true; }
From source file:com.ichi2.anki.Reviewer.java
@SuppressLint("NewApi") @Override/*from w ww . j a v a 2s .c o m*/ public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.reviewer, menu); Resources res = getResources(); if (mCurrentCard != null && mCurrentCard.note().hasTag("marked")) { menu.findItem(R.id.action_mark_card).setTitle(R.string.menu_unmark_note) .setIcon(R.drawable.ic_star_white_24dp); } else { menu.findItem(R.id.action_mark_card).setTitle(R.string.menu_mark_note) .setIcon(R.drawable.ic_star_outline_white_24dp); } if (colIsOpen() && getCol().undoAvailable()) { menu.findItem(R.id.action_undo).setEnabled(true).getIcon().setAlpha(Themes.ALPHA_ICON_ENABLED_LIGHT); } else { menu.findItem(R.id.action_undo).setEnabled(false).getIcon().setAlpha(Themes.ALPHA_ICON_DISABLED_LIGHT); } if (mPrefWhiteboard) { // Don't force showing mark icon when whiteboard enabled // TODO: allow user to customize which icons are force-shown MenuItemCompat.setShowAsAction(menu.findItem(R.id.action_mark_card), MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); // Check if we can forceably squeeze in 3 items into the action bar, if not hide "show whiteboard" if (CompatHelper.getSdkVersion() >= 14 && !ViewConfiguration.get(this).hasPermanentMenuKey()) { // Android 4.x device with overflow menu in the action bar and small screen can't // support forcing 2 extra items into the action bar Display display = getWindowManager().getDefaultDisplay(); DisplayMetrics outMetrics = new DisplayMetrics(); display.getMetrics(outMetrics); float density = getResources().getDisplayMetrics().density; float dpWidth = outMetrics.widthPixels / density; if (dpWidth < 360) { menu.findItem(R.id.action_hide_whiteboard).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } } // Configure the whiteboard related items in the action bar menu.findItem(R.id.action_enable_whiteboard).setTitle(R.string.disable_whiteboard); menu.findItem(R.id.action_hide_whiteboard).setVisible(true); menu.findItem(R.id.action_clear_whiteboard).setVisible(true); Drawable whiteboardIcon = getResources().getDrawable(R.drawable.ic_gesture_white_24dp); if (mShowWhiteboard) { whiteboardIcon.setAlpha(255); menu.findItem(R.id.action_hide_whiteboard).setIcon(whiteboardIcon); menu.findItem(R.id.action_hide_whiteboard).setTitle(R.string.hide_whiteboard); } else { whiteboardIcon.setAlpha(77); menu.findItem(R.id.action_hide_whiteboard).setIcon(whiteboardIcon); menu.findItem(R.id.action_hide_whiteboard).setTitle(R.string.show_whiteboard); } } else { menu.findItem(R.id.action_enable_whiteboard).setTitle(R.string.enable_whiteboard); } if (!CompatHelper.isHoneycomb() && !mDisableClipboard) { menu.findItem(R.id.action_search_dictionary).setVisible(true) .setEnabled(!(mPrefWhiteboard && mShowWhiteboard)) .setTitle(clipboardHasText() ? Lookup.getSearchStringTitle() : res.getString(R.string.menu_select)); } if (getCol().getDecks().isDyn(getParentDid())) { menu.findItem(R.id.action_open_deck_options).setVisible(false); } return super.onCreateOptionsMenu(menu); }