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.uguess.android.sysinfo.ApplicationManager.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { MenuItem mi = menu.add(Menu.NONE, MI_DELETE, Menu.NONE, R.string.uninstall); mi.setIcon(android.R.drawable.ic_menu_delete); Util.setShowAsAction(mi, MenuItem.SHOW_AS_ACTION_IF_ROOM); mi = menu.add(Menu.NONE, MI_SHARE, Menu.NONE, R.string.share); mi.setIcon(android.R.drawable.ic_menu_share); Util.setShowAsAction(mi, MenuItem.SHOW_AS_ACTION_IF_ROOM); if (Util.getSettingsIntent(getActivity().getPackageManager(), "com.android.settings.UsageStats") != null) //$NON-NLS-1$ {/*from ww w .ja v a 2s. co m*/ mi = menu.add(Menu.NONE, MI_USAGE_STATS, Menu.NONE, R.string.usage_stats); mi.setIcon(android.R.drawable.ic_menu_recent_history); Util.setShowAsAction(mi, MenuItem.SHOW_AS_ACTION_NEVER); } mi = menu.add(Menu.NONE, MI_REVERT, Menu.NONE, R.string.restore); mi.setIcon(android.R.drawable.ic_menu_revert); Util.setShowAsAction(mi, MenuItem.SHOW_AS_ACTION_ALWAYS); mi = menu.add(Menu.NONE, MI_PREFERENCE, Menu.NONE, R.string.preference); mi.setIcon(android.R.drawable.ic_menu_preferences); Util.setShowAsAction(mi, MenuItem.SHOW_AS_ACTION_NEVER); }
From source file:com.hughes.android.dictionary.DictionaryActivity.java
@Override public boolean onCreateOptionsMenu(final Menu menu) { if (PreferenceManager.getDefaultSharedPreferences(this) .getBoolean(getString(R.string.showPrevNextButtonsKey), true)) { // Next word. nextWordMenuItem = menu.add(getString(R.string.nextWord)).setIcon(R.drawable.arrow_down_float); MenuItemCompat.setShowAsAction(nextWordMenuItem, MenuItem.SHOW_AS_ACTION_IF_ROOM); nextWordMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override//from w w w .ja va 2 s .c o m public boolean onMenuItemClick(MenuItem item) { onUpDownButton(false); return true; } }); // Previous word. previousWordMenuItem = menu.add(getString(R.string.previousWord)).setIcon(R.drawable.arrow_up_float); MenuItemCompat.setShowAsAction(previousWordMenuItem, MenuItem.SHOW_AS_ACTION_IF_ROOM); previousWordMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { onUpDownButton(true); return true; } }); } randomWordMenuItem = menu.add(getString(R.string.randomWord)); randomWordMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { onRandomWordButton(); return true; } }); application.onCreateGlobalOptionsMenu(this, menu); { final MenuItem dictionaryManager = menu.add(getString(R.string.dictionaryManager)); MenuItemCompat.setShowAsAction(dictionaryManager, MenuItem.SHOW_AS_ACTION_NEVER); dictionaryManager.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(final MenuItem menuItem) { startActivity(DictionaryManagerActivity.getLaunchIntent(getApplicationContext())); finish(); return false; } }); } { final MenuItem aboutDictionary = menu.add(getString(R.string.aboutDictionary)); MenuItemCompat.setShowAsAction(aboutDictionary, MenuItem.SHOW_AS_ACTION_NEVER); aboutDictionary.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(final MenuItem menuItem) { final Context context = getListView().getContext(); final Dialog dialog = new Dialog(context); dialog.setContentView(R.layout.about_dictionary_dialog); final TextView textView = (TextView) dialog.findViewById(R.id.text); final String name = application.getDictionaryName(dictFile.getName()); dialog.setTitle(name); final StringBuilder builder = new StringBuilder(); final DictionaryInfo dictionaryInfo = dictionary.getDictionaryInfo(); dictionaryInfo.uncompressedBytes = dictFile.length(); if (dictionaryInfo != null) { builder.append(dictionaryInfo.dictInfo).append("\n\n"); builder.append(getString(R.string.dictionaryPath, dictFile.getPath())).append("\n"); builder.append(getString(R.string.dictionarySize, dictionaryInfo.uncompressedBytes)) .append("\n"); builder.append(getString(R.string.dictionaryCreationTime, dictionaryInfo.creationMillis)) .append("\n"); for (final IndexInfo indexInfo : dictionaryInfo.indexInfos) { builder.append("\n"); builder.append(getString(R.string.indexName, indexInfo.shortName)).append("\n"); builder.append(getString(R.string.mainTokenCount, indexInfo.mainTokenCount)) .append("\n"); } builder.append("\n"); builder.append(getString(R.string.sources)).append("\n"); for (final EntrySource source : dictionary.sources) { builder.append(getString(R.string.sourceInfo, source.getName(), source.getNumEntries())) .append("\n"); } } textView.setText(builder.toString()); dialog.show(); final WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(); layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT; dialog.getWindow().setAttributes(layoutParams); return false; } }); } return true; }
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 www. ja v a2 s . c o 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:org.alfresco.mobile.android.application.fragments.node.browser.DocumentFolderBrowserFragment.java
public void getMenu(Menu menu) { if (parentFolder == null) { return;/*w ww . j a va2 s. c o m*/ } if (getActivity() instanceof MainActivity) { getMenu(getSession(), menu, parentFolder); if (hasDocument()) { displayMenuItem = menu.add(Menu.NONE, R.id.menu_gallery, Menu.FIRST, R.string.display_gallery); displayMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } } else if (getActivity() instanceof PublicDispatcherActivity || getActivity() instanceof BaseShortcutActivity) { // permission = // getSession().getServiceRegistry().getDocumentFolderService().getPermissions(parentFolder); if (ConfigurableActionHelper.isVisible(getActivity(), getAccount(), getSession(), parentFolder, ConfigurableActionHelper.ACTION_CREATE_FOLDER)) { MenuItem mi = menu.add(Menu.NONE, R.id.menu_create_folder, Menu.FIRST, R.string.folder_create); mi.setIcon(R.drawable.ic_repository_light); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } } MenuFragmentHelper.getMenu(getActivity(), menu); }
From source file:org.opendatakit.survey.activities.MainMenuActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); PropertiesSingleton props = CommonToolProperties.get(this, getAppName()); int showOption = MenuItem.SHOW_AS_ACTION_IF_ROOM; MenuItem item;/* w w w .ja v a2 s. c om*/ if (currentFragment != ScreenList.WEBKIT) { ActionBar actionBar = getActionBar(); actionBar.setCustomView(R.layout.action_bar); actionBar.setDisplayShowCustomEnabled(true); actionBar.show(); item = menu.add(Menu.NONE, MENU_CLOUD_FORMS, Menu.NONE, R.string.sync); item.setIcon(R.drawable.ic_cached_black_24dp).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); item = menu.add(Menu.NONE, MENU_ABOUT, Menu.NONE, R.string.about); item.setIcon(R.drawable.ic_info_outline_black_24dp).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } else { ActionBar actionBar = getActionBar(); actionBar.hide(); } return true; }
From source file:org.alfresco.mobile.android.application.fragments.node.browser.DocumentFolderBrowserFragment.java
public void getMenu(AlfrescoSession session, Menu menu, Folder parentFolder) { MenuItem mi;//from w w w .ja v a 2 s. c o m if (parentFolder == null) { return; } try { permission = session.getServiceRegistry().getDocumentFolderService().getPermissions(parentFolder); } catch (Exception e) { return; } mi = menu.add(Menu.NONE, R.id.menu_search_from_folder, Menu.FIRST + 10, R.string.search); mi.setIcon(R.drawable.ic_search_light); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); if (ConfigurableActionHelper.isVisible(getActivity(), getAccount(), getSession(), parentFolder, ConfigurableActionHelper.ACTION_CREATE_DOC) || ConfigurableActionHelper.isVisible(getActivity(), getAccount(), getSession(), parentFolder, ConfigurableActionHelper.ACTION_CREATE_FOLDER) || ConfigurableActionHelper.isVisible(getActivity(), getAccount(), getSession(), parentFolder, ConfigurableActionHelper.ACTION_NODE_UPLOAD)) { displayFab(); } }
From source file:org.odk.collect.android.activities.FormEntryActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { Collect.getInstance().getActivityLogger().logInstanceAction(this, "onCreateOptionsMenu", "show"); super.onCreateOptionsMenu(menu); if (!hasHardwareMenu) { menu.add(0, MENU_SAVE, 0, R.string.save_all_answers).setIcon(android.R.drawable.ic_menu_save) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); menu.add(0, MENU_HIERARCHY_VIEW, 0, R.string.view_hierarchy).setIcon(R.drawable.ic_menu_goto) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); }/*from w w w. j a v a 2 s . c o m*/ menu.add(0, MENU_LANGUAGES, 0, R.string.change_language).setIcon(R.drawable.ic_menu_start_conversation) .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); menu.add(0, MENU_PREFERENCES, 0, R.string.general_preferences).setIcon(R.drawable.ic_menu_preferences) .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); return true; }
From source file:com.kll.collect.android.activities.FormEntryActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { Collect.getInstance().getActivityLogger().logInstanceAction(this, "onCreateOptionsMenu", "show"); super.onCreateOptionsMenu(menu); CompatibilityUtils.setShowAsAction(/* www . j a v a 2 s . co m*/ menu.add(0, MENU_SAVE, 0, R.string.save_all_answers).setIcon(android.R.drawable.ic_menu_save), MenuItem.SHOW_AS_ACTION_IF_ROOM); CompatibilityUtils.setShowAsAction( menu.add(0, MENU_HIERARCHY_VIEW, 0, R.string.view_hierarchy).setIcon(R.drawable.ic_menu_goto), MenuItem.SHOW_AS_ACTION_IF_ROOM); CompatibilityUtils.setShowAsAction(menu.add(0, MENU_LANGUAGES, 0, R.string.change_language) .setIcon(R.drawable.ic_menu_start_conversation), MenuItem.SHOW_AS_ACTION_NEVER); CompatibilityUtils.setShowAsAction(menu.add(0, MENU_PREFERENCES, 0, R.string.general_preferences) .setIcon(R.drawable.ic_menu_preferences), MenuItem.SHOW_AS_ACTION_NEVER); return true; }
From source file:com.shafiq.mytwittle.view.BaseLaneActivity.java
protected void configureActionBarSearchView(Menu menu) { MenuItem searchItem = menu.findItem(R.id.action_search); mSearchView = (SearchView) searchItem.getActionView(); searchItem.setShowAsActionFlags(/*from w w w.ja v a 2 s . c om*/ MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); mSearchView.setOnQueryTextListener(this); OnFocusChangeListener onFocusChangeListener = new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { mCurrentComposeFragment.setIgnoreFocusChange(true); if (mComposeTweetView != null) { mComposeTweetView.setVisibility(hasFocus ? View.GONE : View.VISIBLE); } if (mComposeDirectMessageView != null) { mComposeDirectMessageView.setVisibility(hasFocus ? View.GONE : View.VISIBLE); } mCurrentComposeFragment.setIgnoreFocusChange(false); } }; mSearchView.setOnQueryTextFocusChangeListener(onFocusChangeListener); mSearchView.setOnFocusChangeListener(onFocusChangeListener); }
From source file:org.tigase.mobile.TigaseMobileMessengerActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { if (getCurrentPage() == 0 || getCurrentPage() == 1 || helper.isXLarge()) { MenuInflater inflater = getMenuInflater(); Log.v(TAG, "current page " + getCurrentPage()); Log.v(TAG, "xlarge = " + helper.isXLarge()); final boolean serviceActive = JaxmppService.isServiceActive(); menu.clear();/*w ww. j av a 2 s. c om*/ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { inflater.inflate(R.menu.main_menu_old, menu); } else { inflater.inflate(R.menu.main_menu, menu); } MenuItem con = menu.findItem(R.id.connectButton); con.setVisible(!serviceActive); MenuItem dcon = menu.findItem(R.id.disconnectButton); dcon.setVisible(serviceActive); MenuItem showOffline = menu.findItem(R.id.showHideOffline); showOffline.setCheckable(true); showOffline.setChecked(mPreferences.getBoolean(Preferences.SHOW_OFFLINE, Boolean.TRUE)); MenuItem add = menu.findItem(R.id.contactAdd); helper.setShowAsAction(add, MenuItem.SHOW_AS_ACTION_IF_ROOM); add.setVisible(serviceActive); MenuItem bookmarks = menu.findItem(R.id.bookmarksShow); if (bookmarks != null) { bookmarks.setVisible(serviceActive); } } return super.onPrepareOptionsMenu(menu); }