List of usage examples for android.view MenuItem SHOW_AS_ACTION_WITH_TEXT
int SHOW_AS_ACTION_WITH_TEXT
To view the source code for android.view MenuItem SHOW_AS_ACTION_WITH_TEXT.
Click Source Link
From source file:lewa.support.v7.app.ActionBarActivityDelegateBase.java
void toggleActionMenuStyle(boolean actionMode) { ArrayList<MenuItemImpl> actionMenus = null; if (!actionMode) { // PanelFeatureState st = window.getPanelState(FEATURE_OPTIONS_PANEL, false); // if (window.isDestroyed() || (st == null || st.menu == null)) { // return; // } // actionMenus = st.menu.lewaGetVisibleItems(); if (mMenu != null) { actionMenus = mMenu.lewaGetVisibleItems(); }/*from w ww . ja v a 2s. c o m*/ } else { if (mActionMode != null) { MenuBuilder menu = (MenuBuilder) mActionMode.getMenu(); if (menu != null) { actionMenus = menu.lewaGetVisibleItems(); } } } if (actionMenus == null) { return; } MenuItemImpl item = null; int actionFlag = 0; int menuStyle = -1; for (int i = 0; i < actionMenus.size(); i++) { item = actionMenus.get(i); actionFlag = item.getShowAsAction(); if (actionFlag == MenuItem.SHOW_AS_ACTION_NEVER) { continue; } if (item.showsTextAsAction()) { menuStyle = ActionBar.LEWA_ACTION_MENU_STYLE_ICON; actionFlag ^= MenuItem.SHOW_AS_ACTION_WITH_TEXT; item.setShowAsAction(actionFlag); } else { menuStyle = ActionBar.LEWA_ACTION_MENU_STYLE_ICON_WITH_TEXT; actionFlag |= MenuItem.SHOW_AS_ACTION_WITH_TEXT; item.setShowAsAction(actionFlag); } saveActionMenuStyle(menuStyle); } }
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;/*from ww w . ja va 2 s .com*/ }
From source file:com.crystal.CrystalBeanWallpapers.Wallpaper.java
@Override public boolean onCreateOptionsMenu(Menu menu) { menu.add(Menu.NONE, MENU_APPLY, 0, R.string.action_apply).setIcon(android.R.drawable.ic_menu_set_as) .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT); return super.onCreateOptionsMenu(menu); }
From source file:org.apache.cordova.plugins.Actionable.java
private void updateButtons(final JSONArray buttons) { for (int i = 0; i < buttons.length(); i++) { try {//from www .ja va 2s . c o m JSONObject btn = buttons.getJSONObject(i); Actionable action = Actionable.fromJSON(btn); action.setFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT); mMenuItems.put(action.getTitle(), action); } catch (Exception e) { Log.v("Cambie", Log.getStackTraceString(e)); } } }
From source file:gov.cdc.epiinfo.RecordList.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); searchView = new SearchView(this); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(false); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override/*www . j a v a 2s .co m*/ public boolean onQueryTextSubmit(String searchTerm) { try { mDbHelper.fetchTopOne(); String query = BuildQuery(searchTerm); String fieldName1; String fieldName2; String fieldName3; String[] from = new String[1]; int[] to = new int[1]; if (formMetadata.DataFields.size() > 2) { fieldName1 = formMetadata.DataFields.get(0).getName(); fieldName2 = formMetadata.DataFields.get(1).getName(); fieldName3 = formMetadata.DataFields.get(2).getName(); mNotesCursor = mDbHelper.fetchWhere(fieldName1, fieldName2, fieldName3, query); from = new String[] { "_id", "columnName1", fieldName1, "columnName2", fieldName2, "columnName3", fieldName3, "_syncStatus" }; to = new int[] { R.id.text1, R.id.header2, R.id.text2, R.id.header3, R.id.text3, R.id.header4, R.id.text4, R.id.hiddenText }; } else if (formMetadata.DataFields.size() == 2) { fieldName1 = formMetadata.DataFields.get(0).getName(); fieldName2 = formMetadata.DataFields.get(1).getName(); mNotesCursor = mDbHelper.fetchWhere(fieldName1, fieldName2, query); from = new String[] { "_id", "columnName1", fieldName1, "columnName2", fieldName2, "_syncStatus" }; to = new int[] { R.id.text1, R.id.header2, R.id.text2, R.id.header3, R.id.text3, R.id.hiddenText }; } else if (formMetadata.DataFields.size() == 1) { fieldName1 = formMetadata.DataFields.get(0).getName(); mNotesCursor = mDbHelper.fetchWhere(fieldName1, query); from = new String[] { "_id", "columnName1", fieldName1, "_syncStatus" }; to = new int[] { R.id.text1, R.id.header2, R.id.text2, R.id.hiddenText }; } startManagingCursor(mNotesCursor); CustomListAdapter notes = new CustomListAdapter(self, R.layout.line_list_row, mNotesCursor, from, to); lineListFragment.setListAdapter(notes); } catch (Exception ex) { fillData(); } return false; } @Override public boolean onQueryTextChange(String newText) { if (newText.equals("")) { fillData(); } return false; } }); mnuSearch = menu.add(0, SEARCH_ID, 0, R.string.menu_search); mnuSearch.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); mnuSearch.setActionView(searchView); mnuSearch.setIcon(gov.cdc.epiinfo.R.drawable.action_search); MenuItem mnuQR = menu.add(0, QR_ID, 1, R.string.menu_barcode); mnuQR.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mnuQR.setIcon(gov.cdc.epiinfo.R.drawable.qrcode_scan); MenuItem mnuCloud = menu.add(0, CLOUD_ID, 2, R.string.menu_cloud_sync); mnuCloud.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT); MenuItem mnuSync = menu.add(0, SYNC_ID, 3, R.string.menu_sync_file); mnuSync.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT); MenuItem mnuDeleteAll = menu.add(0, DELETE_ALL_ID, 4, R.string.menu_delete_all); mnuDeleteAll.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT); if (fkeyGuid == null || fkeyGuid.length() == 0) { mnuSetDefault = menu.add(0, SET_DEFAULT_ID, 5, R.string.set_default_form); mnuSetDefault.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT); mnuExitDefault = menu.add(0, EXIT_DEFAULT_MODE_ID, 5, R.string.exit_default_form); mnuExitDefault.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT); if (AppManager.getDefaultForm().equals("")) { mnuSetDefault.setVisible(true); mnuExitDefault.setVisible(false); } else { mnuSetDefault.setVisible(false); mnuExitDefault.setVisible(true); } } SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); if (sharedPref.getString("cloud_service", "").equals("Box")) { mnuBoxSignin = menu.add(0, BOX_SIGNIN_ID, 6, R.string.box_signin); mnuBoxSignin.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT); mnuBoxSignout = menu.add(0, BOX_SIGNOUT_ID, 6, R.string.box_signout); mnuBoxSignout.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT); if (BoxClient.isAuthenticated(this)) { mnuBoxSignout.setVisible(true); mnuBoxSignin.setVisible(false); } else { mnuBoxSignout.setVisible(false); mnuBoxSignin.setVisible(true); } } MenuItem mnuHelp = menu.add(1, HELP_ID, 7, R.string.menu_help); mnuHelp.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT); return true; }
From source file:com.native5.plugins.ActionBarPlugin.java
private boolean buildMenu(Menu menu, JSONArray definition, String menu_var) { // Sadly MenuItem.setIcon and SubMenu.setIcon have conficting return types (for chaining), thus this can't be done w/ generics :( class GetMenuItemIconTask extends AsyncTask<String, Void, Drawable> { public final MenuItem item; public Exception exception = null; GetMenuItemIconTask(MenuItem item) { this.item = item; }/*from ww w . j ava2s . c o m*/ @Override protected Drawable doInBackground(String... uris) { return getDrawableForURI(uris[0]); } @Override protected void onPostExecute(Drawable icon) { if (icon != null) { item.setIcon(icon); } } } ; class GetSubMenuIconTask extends AsyncTask<String, Void, Drawable> { public final SubMenu item; public Exception exception = null; GetSubMenuIconTask(SubMenu item) { this.item = item; } @Override protected Drawable doInBackground(String... uris) { return getDrawableForURI(uris[0]); } @Override protected void onPostExecute(Drawable icon) { if (icon != null) { item.setIcon(icon); } } } ; try { for (int i = 0; i < definition.length(); ++i) { final JSONObject item_def = definition.getJSONObject(i); final String text = item_def.isNull("text") ? "" : item_def.getString("text"); if (!item_def.has("items")) { MenuItem item = menu.add(0, i, i, text); item.setTitleCondensed(text); if (item_def.isNull("icon") == false) { GetMenuItemIconTask task = new GetMenuItemIconTask(item); synchronized (task) { task.execute(item_def.getString("icon")); } } // Default to MenuItem.SHOW_AS_ACTION_IF_ROOM, otherwise take user defined value. item.setShowAsAction(item_def.has("show") ? item_def.getInt("show") : MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT); menu_callbacks.put(item, "var item = " + menu_var + "[" + i + "]; if(item.click) item.click();"); } else { SubMenu submenu = menu.addSubMenu(0, i, i, text); if (item_def.isNull("icon") == false) { GetSubMenuIconTask task = new GetSubMenuIconTask(submenu); synchronized (task) { task.execute(item_def.getString("icon")); } } // Set submenu header if (item_def.has("header")) { JSONObject header = item_def.getJSONObject("header"); if (header.has("title")) { submenu.setHeaderTitle(header.getString("title")); } if (header.has("icon")) { submenu.setHeaderIcon(getDrawableForURI(header.getString("icon"))); } } // Build sub-menu buildMenu(submenu, item_def.getJSONArray("items"), menu_var + "[" + i + "].items"); } } } catch (JSONException e) { return false; } return true; }
From source file:net.pocketmine.server.HomeActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuItem log = menu.add(0, CONSOLE_CODE, 0, R.string.title_activity_log).setIcon(R.drawable.hardware_dock); MenuItemCompat.setShowAsAction(log, MenuItem.SHOW_AS_ACTION_IF_ROOM); SubMenu sub = menu.addSubMenu(getString(R.string.abs_settings)); /**/*from w w w .j ava 2s .c o m*/ * Set Icon for Submenu */ sub.setIcon(R.drawable.action_settings); /** * Build navigation for submenu */ sub.add(0, VERSION_MANAGER_CODE, 0, getString(R.string.abs_version_manager)); sub.add(0, PROPERTIES_EDITOR_CODE, 0, getString(R.string.abs_properties_editor)); sub.add(0, PLUGINS_CODE, 0, getString(R.string.abs_plugins)); sub.add(0, FORCE_CLOSE_CODE, 0, getString(R.string.abs_force_close)); sub.add(0, ABOUT_US_CODE, 0, getString(R.string.abs_about)); sub.add(0, REINSTALL_PHP_CODE, 0, getString(R.string.php_reinstall)); MenuItem subgrp = sub.getItem(); MenuItemCompat.setShowAsAction(subgrp, MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT); return true; }
From source file:org.alfresco.mobile.android.application.fragments.workflow.task.TaskDetailsFragment.java
public void getMenu(Menu menu) { MenuItem mi;//from ww w .j ava2 s . c o m String processDefinitionKey = WorkflowUtils.getKeyFromProcessDefinitionId(processDefinitionId); if (endedAt == null && processDefinitionKey.startsWith(WorkflowModel.KEY_PREFIX_ACTIVITI)) { mi = menu.add(Menu.NONE, R.id.menu_process_details, Menu.FIRST, R.string.process_diagram); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } mi = menu.add(Menu.NONE, R.id.menu_process_history, Menu.FIRST + 1, R.string.tasks_history); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); if (currentTask == null || endedAt != null) { return; } // unclaim : I unassign myself (generally created by a pooled process) if (currentTask.getAssigneeIdentifier() != null && WorkflowModel.FAMILY_PROCESS_POOLED_REVIEW.contains(processDefinitionKey)) { mi = menu.add(Menu.NONE, R.id.menu_task_unclaim, Menu.FIRST + 2, R.string.task_unclaim); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT); } // reassign : I have a task and I decide I dont want to be responsible // anymore of this task so I reassign to a specific person else if (currentTask.getAssigneeIdentifier() != null) { mi = menu.add(Menu.NONE, R.id.menu_task_reassign, Menu.FIRST + 3, R.string.task_reassign); mi.setIcon(R.drawable.ic_reassign); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } // claim : I assign to me an unassigned task (created by a pooled // process) else if ((currentTask.getAssigneeIdentifier() == null && WorkflowModel.FAMILY_PROCESS_POOLED_REVIEW.contains(processDefinitionKey)) || "unclaimed".equals(state)) { mi = menu.add(Menu.NONE, R.id.menu_task_claim, Menu.FIRST + 4, R.string.task_claim); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT); } }
From source file:org.alfresco.mobile.android.application.activity.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { if (sessionState == SESSION_ERROR && getCurrentSession() == null) { MenuItem mi = menu.add(Menu.NONE, R.id.menu_account_reload, Menu.FIRST, R.string.retry_account_loading); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT | MenuItem.SHOW_AS_ACTION_ALWAYS); }// w w w . j ava2 s . c o m return super.onCreateOptionsMenu(menu); }
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); }/*w ww . j a va2 s . c om*/ 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; }