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:org.catnut.fragment.ProfileFragment.java
private void buildMenu() { if (mMenu != null && mAvatarUrl != null) { // ???sqlite // ???menu if (mMenu.findItem(R.id.action_follow) == null && mMenu.findItem(R.id.action_unfollow) == null) { if (!mFollowing) { mMenu.add(Menu.NONE, R.id.action_follow, Menu.NONE, R.string.follow) .setIcon(R.drawable.ic_title_follow).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } else { mMenu.add(Menu.NONE, R.id.action_unfollow, Menu.NONE, R.string.unfollow) .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); }//ww w .j a v a 2 s . c o m } } }
From source file:org.catnut.fragment.ProfileFragment.java
private void toggleFollow(final boolean follow) { mApp.getRequestQueue()//from ww w. j a v a 2 s .co m .add(new CatnutRequest(getActivity(), follow ? FriendshipsAPI.create(mScreenName, null) : FriendshipsAPI.destroy(mScreenName), new UserProcessor.UserProfileProcessor(), new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { Toast.makeText(getActivity(), getString(follow ? R.string.follow_success : R.string.unfollow_success), Toast.LENGTH_SHORT).show(); if (follow) { mMenu.removeItem(R.id.action_follow); mMenu.add(Menu.NONE, R.id.action_follow, Menu.NONE, R.string.unfollow) .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } else { mMenu.removeItem(R.id.action_unfollow); mMenu.add(Menu.NONE, R.id.action_follow, Menu.NONE, R.string.follow) .setIcon(R.drawable.ic_title_follow) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } mFollowing = !mFollowing; // ? final String str = follow ? "+1" : "-1"; new Thread(new Runnable() { @Override public void run() { long uid = mApp.getAccessToken().uid; String update = "update " + User.TABLE + " SET " + User.friends_count + "=" + User.friends_count + str + " WHERE " + BaseColumns._ID + "=" + uid; getActivity().getContentResolver().update( CatnutProvider.parse(User.MULTIPLE, uid), null, update, null); } }).start(); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Toast.makeText(getActivity(), error.getLocalizedMessage(), Toast.LENGTH_SHORT) .show(); } })); }
From source file:org.alfresco.mobile.android.application.accounts.fragment.AccountDetailsFragment.java
public void getMenu(Menu menu) { MenuItem mi;//from ww w . ja v a 2 s . co m if (acc.getActivation() == null) { mi = menu.add(Menu.NONE, MenuActionItem.MENU_ACCOUNT_EDIT, Menu.FIRST + MenuActionItem.MENU_ACCOUNT_EDIT, String.format(getString(R.string.account_edit_hint), acc.getDescription())); mi.setIcon(R.drawable.ic_edit); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } mi = menu.add(Menu.NONE, MenuActionItem.MENU_ACCOUNT_DELETE, Menu.FIRST + MenuActionItem.MENU_ACCOUNT_DELETE, String.format(getString(R.string.account_delete_hint), acc.getDescription())); mi.setIcon(R.drawable.ic_delete); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); }
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. ja v a 2 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:com.grarak.kerneladiutor.fragments.RecyclerViewFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); if (!hideBanner()) return;//from w w w . j a v a 2 s.co m if (showViewPager()) { menu.add(0, 0, Menu.NONE, R.string.options) .setIcon(ContextCompat.getDrawable(getActivity(), R.drawable.ic_launcher_preview)) .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM); } if (showTopFab()) { menu.add(0, 1, Menu.NONE, R.string.more).setIcon(getTopFabDrawable()) .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM); } else if (showBottomFab()) { menu.add(0, 1, Menu.NONE, R.string.more).setIcon(getBottomFabDrawable()) .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM); } }
From source file:com.concentricsky.android.khanacademy.app.VideoDetailActivity.java
private void prepareDownloadActionItem(MenuItem item, int downloadPercent) { item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); int dlRes = R.drawable.av_download; int removeRes = R.drawable.content_discard; switch (downloadPercent) { case PARAM_PROGRESS_DONE: videoIsDownloaded = true;/*from www. j a va 2s .c o m*/ item.setEnabled(true).setTitle("Downloaded").setIcon(getResources().getDrawable(removeRes)); break; case PARAM_PROGRESS_UNKNOWN: if (video != null) { try { dataService.getHelper().getVideoDao().refresh(video); } catch (SQLException e) { e.printStackTrace(); } switch (video.getDownload_status()) { case Video.DL_STATUS_COMPLETE: videoIsDownloaded = true; item.setEnabled(true).setTitle("Downloaded").setIcon(getResources().getDrawable(removeRes)); break; case Video.DL_STATUS_IN_PROGRESS: videoIsDownloaded = false; item.setEnabled(false).setTitle("Downloading").setIcon(getResources().getDrawable(dlRes)); break; case Video.DL_STATUS_NOT_STARTED: default: videoIsDownloaded = false; item.setEnabled(true).setTitle("Download").setIcon(getResources().getDrawable(dlRes)); } } break; default: videoIsDownloaded = false; item.setEnabled(false).setTitle(downloadPercent + "%").setIcon(null); } }
From source file:org.woltage.irssiconnectbot.ConsoleActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); View view = findCurrentView(R.id.console_flip); final TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); final boolean activeTerminal = (view instanceof TerminalView); boolean sessionOpen = false; boolean disconnected = false; boolean canForwardPorts = false; if (activeTerminal) { TerminalBridge bridge = ((TerminalView) view).bridge; sessionOpen = bridge.isSessionOpen(); disconnected = bridge.isDisconnected(); canForwardPorts = bridge.canFowardPorts(); }//from ww w.j a v a 2 s .co m menu.setQwertyMode(true); disconnect = menu.add(R.string.list_host_disconnect); if (hardKeyboard) disconnect.setAlphabeticShortcut('w'); if (!sessionOpen && disconnected) disconnect.setTitle(R.string.console_menu_close); disconnect.setEnabled(activeTerminal); disconnect.setIcon(android.R.drawable.ic_menu_close_clear_cancel); disconnect.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { // disconnect or close the currently visible session TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); TerminalBridge bridge = terminalView.bridge; bridge.dispatchDisconnect(true); if (bound != null && prefs.getBoolean("unloadKeysOnDisconnect", true)) { bound.lockUnusedKeys(); } return true; } }); copy = menu.add(R.string.console_menu_copy); if (hardKeyboard) copy.setAlphabeticShortcut('c'); copy.setIcon(android.R.drawable.ic_menu_set_as); copy.setEnabled(activeTerminal); copy.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { // mark as copying and reset any previous bounds TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); copySource = terminalView.bridge; SelectionArea area = copySource.getSelectionArea(); area.reset(); area.setBounds(copySource.buffer.getColumns(), copySource.buffer.getRows()); area.setRow(copySource.buffer.getCursorRow()); area.setColumn(copySource.buffer.getCursorColumn()); copySource.setSelectingForCopy(true); // Make sure we show the initial selection copySource.redraw(); Toast.makeText(ConsoleActivity.this, getString(R.string.console_copy_start), Toast.LENGTH_LONG) .show(); return true; } }); paste = menu.add(R.string.console_menu_paste); if (hardKeyboard) paste.setAlphabeticShortcut('v'); paste.setIcon(android.R.drawable.ic_menu_edit); paste.setEnabled(clipboard.hasText() && sessionOpen); paste.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { // force insert of clipboard text into current console TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); TerminalBridge bridge = terminalView.bridge; // pull string from clipboard and generate all events to force // down String clip = clipboard.getText().toString(); bridge.injectString(clip); return true; } }); portForward = menu.add(R.string.console_menu_portforwards); if (hardKeyboard) portForward.setAlphabeticShortcut('f'); portForward.setIcon(android.R.drawable.ic_menu_manage); portForward.setEnabled(sessionOpen && canForwardPorts); portForward.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); TerminalBridge bridge = terminalView.bridge; Intent intent = new Intent(ConsoleActivity.this, PortForwardListActivity.class); intent.putExtra(Intent.EXTRA_TITLE, bridge.host.getId()); ConsoleActivity.this.startActivityForResult(intent, REQUEST_EDIT); return true; } }); urlscan = menu.add(R.string.console_menu_urlscan); if (hardKeyboard) urlscan.setAlphabeticShortcut('u'); urlscan.setIcon(android.R.drawable.ic_menu_search); urlscan.setEnabled(activeTerminal); urlscan.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { final TerminalView terminal = (TerminalView) findCurrentView(R.id.console_flip); TerminalKeyListener handler = terminal.bridge.getKeyHandler(); handler.urlScan(terminal); return true; } }); resize = menu.add(R.string.console_menu_resize); if (hardKeyboard) resize.setAlphabeticShortcut('s'); resize.setIcon(android.R.drawable.ic_menu_crop); resize.setEnabled(sessionOpen); resize.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { final TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); final View resizeView = inflater.inflate(R.layout.dia_resize, null, false); ((EditText) resizeView.findViewById(R.id.width)) .setText(prefs.getString("default_fsize_width", "80")); ((EditText) resizeView.findViewById(R.id.height)) .setText(prefs.getString("default_fsize_height", "25")); new AlertDialog.Builder(ConsoleActivity.this).setView(resizeView) .setPositiveButton(R.string.button_resize, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { int width, height; try { width = Integer.parseInt( ((EditText) resizeView.findViewById(R.id.width)).getText().toString()); height = Integer.parseInt( ((EditText) resizeView.findViewById(R.id.height)).getText().toString()); } catch (NumberFormatException nfe) { // TODO change this to a real dialog where we can // make the input boxes turn red to indicate an error. return; } if (width > 0 && height > 0) { terminalView.forceSize(width, height); terminalView.bridge.parentChanged(terminalView); } else { new AlertDialog.Builder(ConsoleActivity.this) .setMessage("Width and height must be higher than zero.") .setTitle("Error").show(); } } }).setNegativeButton(android.R.string.cancel, null).create().show(); return true; } }); MenuItem ctrlKey = menu.add("Ctrl"); ctrlKey.setEnabled(activeTerminal); ctrlKey.setIcon(R.drawable.button_ctrl); MenuItemCompat.setShowAsAction(ctrlKey, MenuItem.SHOW_AS_ACTION_IF_ROOM); ctrlKey.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { View flip = findCurrentView(R.id.console_flip); if (flip == null) return false; TerminalView terminal = (TerminalView) flip; TerminalKeyListener handler = terminal.bridge.getKeyHandler(); handler.metaPress(TerminalKeyListener.META_CTRL_ON); terminal.bridge.tryKeyVibrate(); return true; } }); MenuItem escKey = menu.add("Esc"); escKey.setEnabled(activeTerminal); escKey.setIcon(R.drawable.button_esc); MenuItemCompat.setShowAsAction(escKey, MenuItem.SHOW_AS_ACTION_IF_ROOM); escKey.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { View flip = findCurrentView(R.id.console_flip); if (flip == null) return false; TerminalView terminal = (TerminalView) flip; TerminalKeyListener handler = terminal.bridge.getKeyHandler(); handler.sendEscape(); terminal.bridge.tryKeyVibrate(); return true; } }); MenuItem symKey = menu.add("SYM"); symKey.setEnabled(activeTerminal); symKey.setIcon(R.drawable.button_sym); MenuItemCompat.setShowAsAction(symKey, MenuItem.SHOW_AS_ACTION_IF_ROOM); symKey.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { View flip = findCurrentView(R.id.console_flip); if (flip == null) return false; TerminalView terminal = (TerminalView) flip; TerminalKeyListener handler = terminal.bridge.getKeyHandler(); handler.showCharPickerDialog(terminal); return true; } }); MenuItem inputButton = menu.add("Input"); inputButton.setEnabled(activeTerminal); inputButton.setIcon(R.drawable.button_input); MenuItemCompat.setShowAsAction(inputButton, MenuItem.SHOW_AS_ACTION_IF_ROOM); inputButton.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { View flip = findCurrentView(R.id.console_flip); if (flip == null) return false; final TerminalView terminal = (TerminalView) flip; Thread promptThread = new Thread(new Runnable() { public void run() { String inj = getCurrentPromptHelper().requestStringPrompt(null, ""); terminal.bridge.injectString(inj); } }); promptThread.setName("Prompt"); promptThread.setDaemon(true); promptThread.start(); return true; } }); MenuItem keyboard = menu.add("Show Keyboard"); keyboard.setEnabled(activeTerminal); keyboard.setIcon(R.drawable.button_keyboard); MenuItemCompat.setShowAsAction(keyboard, MenuItem.SHOW_AS_ACTION_IF_ROOM); keyboard.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { View flip = findCurrentView(R.id.console_flip); if (flip == null) return false; inputManager.showSoftInput(flip, InputMethodManager.SHOW_FORCED); return true; } }); MenuItem keys = menu.add(R.string.console_menu_pubkeys); keys.setIcon(android.R.drawable.ic_lock_lock); keys.setIntent(new Intent(this, PubkeyListActivity.class)); keys.setEnabled(activeTerminal); keys.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { Intent intent = new Intent(ConsoleActivity.this, PubkeyListActivity.class); intent.putExtra(PubkeyListActivity.PICK_MODE, true); ConsoleActivity.this.startActivityForResult(intent, REQUEST_SELECT); return true; } }); return true; }
From source file:org.alfresco.mobile.android.application.fragments.browser.ChildrenBrowserFragment.java
public void getMenu(Menu menu) { if (parentFolder == null) { return;/*from w ww .ja va 2s .co m*/ } if (getActivity() instanceof MainActivity) { getMenu(alfSession, menu, parentFolder); if (hasDocument()) { displayMenuItem = menu.add(Menu.NONE, MenuActionItem.MENU_DISPLAY_GALLERY, Menu.FIRST + MenuActionItem.MENU_DISPLAY_GALLERY, R.string.display_gallery); displayMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } } else if (getActivity() instanceof PublicDispatcherActivity) { Permissions permission = alfSession.getServiceRegistry().getDocumentFolderService() .getPermissions(parentFolder); if (permission.canAddChildren()) { MenuItem 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); } } // Uncomment for enabling view switcher /* * displayMenuItem = menu.add(Menu.NONE, * MenuActionItem.MENU_DISPLAY_ITEMS, Menu.FIRST + * MenuActionItem.MENU_DISPLAY_ITEMS, R.string.display_views); switch * (displayMode) { case DISPLAY_LIST: * displayMenuItem.setIcon(R.drawable.ic_action_list); break; case * DISPLAY_LIST_LARGE: * displayMenuItem.setIcon(R.drawable.ic_action_tiles_small); break; * case DISPLAY_GRID: * displayMenuItem.setIcon(R.drawable.ic_action_list_2); break; default: * break; } * displayMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); */ }
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;// w w w .j a v a2s . 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;/*from w w w . j a v a 2 s. co 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; }