List of usage examples for android.view MenuItem SHOW_AS_ACTION_ALWAYS
int SHOW_AS_ACTION_ALWAYS
To view the source code for android.view MenuItem SHOW_AS_ACTION_ALWAYS.
Click Source Link
From source file:io.mpos.ui.shared.view.SummaryFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { if (showSendReceiptButton()) { menu.add(Menu.NONE, R.id.mpu_send_receipt_action_id, Menu.NONE, R.string.MPUSend) .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); }/* w ww . java2 s.c om*/ super.onCreateOptionsMenu(menu, inflater); }
From source file:org.alfresco.mobile.android.application.extension.samsung.pen.SNoteEditorActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { toolsSubMenu = menu.addSubMenu(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_TOOLS, Menu.FIRST, R.string.editor_tools);/*w ww . j a v a2 s. c o m*/ toolsSubMenu.setIcon(R.drawable.ic_edit); toolsSubMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); // TOOLS MENU MenuItem mi = toolsSubMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_PEN, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_PEN, R.string.editor_pen); mi.setIcon(R.drawable.ic_edit); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mi = toolsSubMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_TEXT, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_TEXT, R.string.editor_text); mi.setIcon(R.drawable.ic_text); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mi = toolsSubMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_SELECTION, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_SELECTION, R.string.editor_selection); mi.setIcon(R.drawable.ic_selection); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mi = toolsSubMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_ERASER, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_ERASER, R.string.editor_eraser); mi.setIcon(R.drawable.ic_eraser); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); // TOOL SETTINGS MENU SubMenu toolsSettingSubMenu = menu.addSubMenu(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_SETTINGS, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_SETTINGS, R.string.editor_tools_settings); toolsSettingSubMenu.setIcon(R.drawable.ic_action_settings); toolsSettingSubMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); mi = toolsSettingSubMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_SETTINGS_PEN, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_SETTINGS_PEN, R.string.editor_pen); mi.setIcon(R.drawable.ic_edit); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mi = toolsSettingSubMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_SETTINGS_TEXT, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_SETTINGS_TEXT, R.string.editor_text); mi.setIcon(R.drawable.ic_text); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mi = toolsSettingSubMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_SETTINGS_SELECTION, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_SETTINGS_SELECTION, R.string.editor_selection); mi.setIcon(R.drawable.ic_selection); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mi = toolsSettingSubMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_SETTINGS_ERASER, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_SETTINGS_ERASER, R.string.editor_eraser); mi.setIcon(R.drawable.ic_eraser); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); // ADD MENU SubMenu addSubMenu = menu.addSubMenu(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_ADD, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_ADD, R.string.editor_add_menu); addSubMenu.setIcon(R.drawable.ic_add); addSubMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); // IMAGE mi = addSubMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_ADD_IMAGE, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_ADD_IMAGE, R.string.editor_add_image); mi.setIcon(R.drawable.ic_add_image); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); // PAGES SubMenu pagesMenu = menu.addSubMenu(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_PAGE, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_PAGE, R.string.editor_pages); pagesMenu.setIcon(R.drawable.ic_pages); pagesMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); mi = pagesMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_PAGE_MOVE, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_PAGE_MOVE, R.string.editor_pages_move); mi.setIcon(R.drawable.ic_pages); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mi = pagesMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_PAGE_ADD, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_PAGE_ADD, R.string.editor_pages_add); mi.setIcon(R.drawable.ic_add_page); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mi = pagesMenu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_PAGE_DELETE, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_PAGE_DELETE, R.string.editor_pages_remove); mi.setIcon(R.drawable.ic_delete); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); // EXTRA SETTINGS // SAVE mi = menu.add(Menu.NONE, SNoteMenuActionItem.MENU_EDITOR_SAVE, Menu.FIRST + SNoteMenuActionItem.MENU_EDITOR_SAVE, R.string.editor_save); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); super.onCreateOptionsMenu(menu); return true; }
From source file:tw.com.geminihsu.app01.fragment.Fragment_Client_Service.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { MenuItem item = menu.add(Menu.NONE, ACTIONBAR_MENU_ITEM_FIILTER, Menu.NONE, getString(R.string.order_call_taxi_page_title)); SpannableString spanString = new SpannableString(item.getTitle().toString()); spanString.setSpan(new ForegroundColorSpan(Color.WHITE), 0, spanString.length(), 0); //fix the color to white item.setTitle(spanString);//from w ww.ja v a 2 s . c o m if (isShowOneKey) item.setVisible(true); else item.setVisible(false); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); super.onCreateOptionsMenu(menu, inflater); }
From source file:com.mishiranu.dashchan.ui.navigator.page.PostsPage.java
@Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { PageHolder pageHolder = getPageHolder(); ChanConfiguration configuration = getChanConfiguration(); getAdapter().setSelectionModeEnabled(true); mode.setTitle(getString(R.string.text_selected_format, 0)); int pasteResId = ResourceUtils.getSystemSelectionIcon(getActivity(), "actionModePasteDrawable", "ic_menu_paste_holo_dark"); int flags = MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT; ChanConfiguration.Board board = configuration.safe().obtainBoard(pageHolder.boardName); menu.add(0, ACTION_MENU_MAKE_THREADSHOT, 0, R.string.action_make_threadshot) .setIcon(obtainIcon(R.attr.actionMakeThreadshot)).setShowAsAction(flags); if (replyable != null) { menu.add(0, ACTION_MENU_REPLY, 0, R.string.action_reply).setIcon(pasteResId).setShowAsAction(flags); }// www. j a v a 2s .co m if (board.allowDeleting) { ChanConfiguration.Deleting deleting = configuration.safe().obtainDeleting(pageHolder.boardName); if (deleting != null && deleting.multiplePosts) { menu.add(0, ACTION_MENU_DELETE_POSTS, 0, R.string.action_delete) .setIcon(obtainIcon(R.attr.actionDelete)).setShowAsAction(flags); } } if (board.allowReporting) { ChanConfiguration.Reporting reporting = configuration.safe().obtainReporting(pageHolder.boardName); if (reporting != null && reporting.multiplePosts) { menu.add(0, ACTION_MENU_SEND_REPORT, 0, R.string.action_report) .setIcon(obtainIcon(R.attr.actionReport)).setShowAsAction(flags); } } return true; }
From source file:gov.wa.wsdot.android.wsdot.ui.trafficmap.TrafficMapActivity.java
/** * Set up the App bar menu//from w w w . j a v a2 s.c o m * * Loop through all menu items, checking ID for set up. * We do it this way because item indices aren't set since the menu is dynamic. * (ex. travel charts may be added to the start) * * @param menu * @return */ @Override public boolean onPrepareOptionsMenu(Menu menu) { menu.clear(); getMenuInflater().inflate(R.menu.traffic, menu); if (bestTimesAvailable) { menu.add(0, R.id.best_times_to_travel, 0, "Best Times to Travel").setIcon(R.drawable.ic_menu_chart) .setActionView(R.layout.action_bar_notification_icon) .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); final MenuItem chartMenuItem = menu.findItem(R.id.best_times_to_travel); // Since we added an action view, need to hook up the onclick ourselves. chartMenuItem.getActionView() .setOnClickListener(v -> TrafficMapActivity.this.onMenuItemSelected(0, chartMenuItem)); menu_item_refresh = 2; } else { menu_item_refresh = 1; } for (int i = 0; i < menu.size(); i++) { switch (menu.getItem(i).getItemId()) { case R.id.toggle_cameras: if (showCameras) { menu.getItem(i).setTitle("Hide Cameras"); menu.getItem(i).setIcon(R.drawable.ic_menu_traffic_cam); } else { menu.getItem(i).setTitle("Show Cameras"); menu.getItem(i).setIcon(R.drawable.ic_menu_traffic_cam_off); } break; default: break; } } return super.onPrepareOptionsMenu(menu); }
From source file:org.alfresco.mobile.android.application.fragments.browser.ChildrenBrowserFragment.java
public static void getMenu(AlfrescoSession session, Menu menu, Folder parentFolder, boolean actionMode) { MenuItem mi;//from ww w . j av a2 s. c o m if (parentFolder == null) { return; } Permissions permission = null; try { permission = session.getServiceRegistry().getDocumentFolderService().getPermissions(parentFolder); } catch (Exception e) { return; } if (!actionMode) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_SEARCH_FOLDER, Menu.FIRST + MenuActionItem.MENU_SEARCH_FOLDER, R.string.search); mi.setIcon(R.drawable.ic_search); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } if (!actionMode && permission.canAddChildren()) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_CREATE_FOLDER, Menu.FIRST + MenuActionItem.MENU_CREATE_FOLDER, R.string.folder_create); mi.setIcon(R.drawable.ic_add_folder); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); SubMenu createMenu = menu.addSubMenu(Menu.NONE, MenuActionItem.MENU_DEVICE_CAPTURE, Menu.FIRST + MenuActionItem.MENU_DEVICE_CAPTURE, R.string.add_menu); createMenu.setIcon(android.R.drawable.ic_menu_add); createMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); createMenu.add(Menu.NONE, MenuActionItem.MENU_UPLOAD, Menu.FIRST + MenuActionItem.MENU_UPLOAD, R.string.upload_title); createMenu.add(Menu.NONE, MenuActionItem.MENU_CREATE_DOCUMENT, Menu.FIRST + MenuActionItem.MENU_CREATE_DOCUMENT, R.string.create_document); createMenu.add(Menu.NONE, MenuActionItem.MENU_DEVICE_CAPTURE_CAMERA_PHOTO, Menu.FIRST + MenuActionItem.MENU_DEVICE_CAPTURE_CAMERA_PHOTO, R.string.take_photo); if (AndroidVersion.isICSOrAbove()) { createMenu.add(Menu.NONE, MenuActionItem.MENU_DEVICE_CAPTURE_CAMERA_VIDEO, Menu.FIRST + MenuActionItem.MENU_DEVICE_CAPTURE_CAMERA_VIDEO, R.string.make_video); } createMenu.add(Menu.NONE, MenuActionItem.MENU_DEVICE_CAPTURE_MIC_AUDIO, Menu.FIRST + MenuActionItem.MENU_DEVICE_CAPTURE_MIC_AUDIO, R.string.record_audio); } if (actionMode) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_DETAILS, Menu.FIRST + MenuActionItem.MENU_DETAILS, R.string.action_view_properties); mi.setIcon(R.drawable.ic_details); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } if (actionMode && permission.canEdit()) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_EDIT, Menu.FIRST + MenuActionItem.MENU_EDIT, R.string.edit); mi.setIcon(R.drawable.ic_edit); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } if (actionMode && permission.canDelete()) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_DELETE, Menu.FIRST + MenuActionItem.MENU_DELETE, R.string.delete); mi.setIcon(R.drawable.ic_delete); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } if (!actionMode) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_REFRESH, Menu.FIRST + MenuActionItem.MENU_REFRESH, R.string.refresh); mi.setIcon(R.drawable.ic_refresh); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } }
From source file:nl.sogeti.android.gpstracker.viewer.LoggerMap.java
@Override public boolean onCreateOptionsMenu(Menu menu) { boolean result = super.onCreateOptionsMenu(menu); MenuItem item;// w w w . ja va 2 s. c o m item = menu.add(ContextMenu.NONE, MENU_TRACKLIST, ContextMenu.NONE, R.string.menu_tracklist) .setIcon(R.drawable.ic_list_24dp).setAlphabeticShortcut('P'); MenuItemCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_ALWAYS); item = menu.add(ContextMenu.NONE, MENU_STATS, ContextMenu.NONE, R.string.menu_statistics) .setIcon(R.drawable.ic_graph_24dp).setAlphabeticShortcut('S'); MenuItemCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_ALWAYS); item = menu.add(ContextMenu.NONE, MENU_SHARE, ContextMenu.NONE, R.string.menu_shareTrack) .setIcon(R.drawable.ic_share_24dp).setAlphabeticShortcut('I'); MenuItemCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_IF_ROOM); item = menu.add(ContextMenu.NONE, MENU_LAYERS, ContextMenu.NONE, R.string.menu_showLayers) .setIcon(R.drawable.ic_layers_24dp).setAlphabeticShortcut('L'); MenuItemCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_IF_ROOM); item = menu.add(ContextMenu.NONE, MENU_NOTE, ContextMenu.NONE, R.string.menu_insertnote) .setIcon(R.drawable.ic_pin_drop_24dp); MenuItemCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_IF_ROOM); item = menu.add(ContextMenu.NONE, MENU_SETTINGS, ContextMenu.NONE, R.string.menu_settings) .setIcon(R.drawable.ic_menu_preferences).setAlphabeticShortcut('C'); MenuItemCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_NEVER); return result; }
From source file:tw.com.geminihsu.app01.fragment.Fragment_PickUpAirPlane.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { MenuItem item = menu.add(Menu.NONE, ACTIONBAR_MENU_ITEM_SUMMIT, Menu.NONE, getString(R.string.menu_take)); SpannableString spanString = new SpannableString(item.getTitle().toString()); spanString.setSpan(new ForegroundColorSpan(Color.WHITE), 0, spanString.length(), 0); //fix the color to white item.setTitle(spanString);//from w w w.j a v a 2 s . co m item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); super.onCreateOptionsMenu(menu, inflater); }
From source file:com.nachiket.titan.LibraryActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { MenuItem controls = menu.add(null); CompatHoneycomb.setActionView(controls, mActionControls); CompatHoneycomb.setShowAsAction(controls, MenuItem.SHOW_AS_ACTION_ALWAYS); MenuItem search = menu.add(0, MENU_SEARCH, 0, R.string.search).setIcon(R.drawable.ic_menu_search); CompatHoneycomb.setShowAsAction(search, MenuItem.SHOW_AS_ACTION_IF_ROOM); } else {//from ww w.j a va 2 s . co m menu.add(0, MENU_SEARCH, 0, R.string.search).setIcon(R.drawable.ic_menu_search); menu.add(0, MENU_PLAYBACK, 0, R.string.playback_view).setIcon(R.drawable.ic_menu_gallery); } menu.add(0, MENU_SORT, 0, R.string.sort_by).setIcon(R.drawable.ic_menu_sort_alphabetically); return super.onCreateOptionsMenu(menu); }
From source file:com.mishiranu.dashchan.ui.navigator.NavigatorActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { if (searchMode) { currentMenu = null;//from w ww . ja v a2 s . c om menu.add(0, ListPage.OPTIONS_MENU_SEARCH_VIEW, 0, "").setActionView(getSearchView(true)) .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); } else { currentMenu = menu; if (page != null) { page.onCreateOptionsMenu(menu); sendPrepareMenuToPage = true; } MenuItem appearanceOptionsItem = menu.findItem(ListPage.OPTIONS_MENU_APPEARANCE); if (appearanceOptionsItem != null) { Menu appearanceOptionsMenu = appearanceOptionsItem.getSubMenu(); appearanceOptionsMenu.add(0, ListPage.APPEARANCE_MENU_CHANGE_THEME, 0, R.string.action_change_theme); appearanceOptionsMenu .add(0, ListPage.APPEARANCE_MENU_EXPANDED_SCREEN, 0, R.string.action_expanded_screen) .setCheckable(true); appearanceOptionsMenu.add(0, ListPage.APPEARANCE_MENU_SPOILERS, 0, R.string.action_spoilers) .setCheckable(true); appearanceOptionsMenu.add(0, ListPage.APPEARANCE_MENU_MY_POSTS, 0, R.string.action_my_posts) .setCheckable(true); appearanceOptionsMenu.add(0, ListPage.APPEARANCE_MENU_DRAWER, 0, R.string.action_lock_drawer) .setCheckable(true); appearanceOptionsMenu.add(0, ListPage.APPEARANCE_MENU_THREADS_GRID, 0, R.string.action_threads_grid) .setCheckable(true); appearanceOptionsMenu.add(0, ListPage.APPEARANCE_MENU_SFW_MODE, 0, R.string.action_sfw_mode) .setCheckable(true); } actionMenuConfigurator.onAfterCreateOptionsMenu(menu); } return true; }