List of usage examples for android.view MenuItem setShowAsAction
public void setShowAsAction(int actionEnum);
From source file:com.pacoapp.paco.ui.FindMyExperimentsActivity.java
@SuppressLint("NewApi") @Override//from www. ja va 2 s . co m public boolean onCreateOptionsMenu(Menu menu) { int pos = 1; if (true || !mNavigationDrawerFragment.isDrawerOpen()) { getMenuInflater().inflate(R.menu.main, menu); // restoreActionBar(); // TODO hide find experiments (this is that item) // TODO make refresh be an always action MenuItem findExperiments = menu.getItem(0); findExperiments.setVisible(false); MenuItem refreshExperiments = menu.getItem(1); refreshExperiments.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); return true; } return super.onCreateOptionsMenu(menu); }
From source file:de.kaidev.vertretungsplanapp.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuItem info = menu.add(0, 99, 0, "Info").setIcon(R.drawable.ic_info_outline_white_48dp); info.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); int i = mPager != null ? mPager.getCurrentItem() : 0; String s = i == 0 ? heute.getInfo() : morgen.getInfo(); if (!s.isEmpty()) { for (String t : s.split("\n")) { if (!t.startsWith("Abwesende") && !t.startsWith("Blockierte")) { info.setIcon(R.drawable.ic_info_white_48dp); break; }//w w w. j a v a 2s . c om } } return super.onCreateOptionsMenu(menu); }
From source file:com.money.manager.ex.search.SearchParametersFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { UIHelper ui = new UIHelper(getActivity()); // 'Reset' toolbar item inflater.inflate(R.menu.menu_clear, menu); MenuItem item = menu.findItem(R.id.clearMenuItem); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); item.setIcon(ui.getIcon(GoogleMaterial.Icon.gmd_clear)); super.onCreateOptionsMenu(menu, inflater); }
From source file:org.alfresco.mobile.android.application.fragments.menu.MainMenuFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { menu.clear();/* w w w. j ava 2 s .c o m*/ if (showOperationsMenu) { MenuItem mi = menu.add(Menu.NONE, R.id.menu_notifications, Menu.FIRST, R.string.notifications); mi.setIcon(R.drawable.ic_events_dark); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } }
From source file:org.alfresco.mobile.android.application.fragments.fileexplorer.FileActions.java
private void getMenu(Menu menu) { menu.clear();/* ww w .j a va 2 s. c o m*/ MenuItem mi; if (getFragment() instanceof ListingModeFragment) { switch (((ListingModeFragment) getFragment()).getMode()) { case FileExplorerFragment.MODE_LISTING: if (selectedFolder.isEmpty()) { mi = menu.add(Menu.NONE, R.id.menu_upload, Menu.FIRST + 30, R.string.upload); mi.setIcon(R.drawable.ic_upload); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); mi = menu.add(Menu.NONE, R.id.menu_action_share, Menu.FIRST + 100, R.string.share); mi.setIcon(R.drawable.ic_share); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } mi = menu.add(Menu.NONE, R.id.menu_action_delete, Menu.FIRST + 1000, R.string.delete); mi.setIcon(R.drawable.ic_delete); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); break; case FileExplorerFragment.MODE_PICK: if (selectedFolder.isEmpty()) { mi = menu.add(Menu.NONE, R.id.menu_file_send, Menu.FIRST, R.string.action_upload); mi.setIcon(R.drawable.ic_upload); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT | MenuItem.SHOW_AS_ACTION_ALWAYS); } break; default: break; } mi = menu.add(Menu.NONE, R.id.menu_select_all, Menu.FIRST + 200, R.string.select_all); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } }
From source file:com.ustadmobile.port.android.view.CatalogOPDSFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { if (mDeleteOptionAvailable && mSelectedEntries.length > 0) { MenuItem item = menu.add(Menu.NONE, MENUCMDID_DELETE, 1, ""); item.setIcon(R.drawable.ic_delete_white_24dp); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); }// w w w .j a v a 2 s .com super.onCreateOptionsMenu(menu, inflater); }
From source file:org.alfresco.mobile.android.application.fragments.actions.NodeActions.java
protected void getMenu(FragmentActivity activity, Menu menu) { MenuItem mi; SubMenu createMenu;/*from ww w . ja v a 2 s .c om*/ if (selectedFolder.isEmpty()) { mi = menu.add(Menu.NONE, R.id.menu_action_download_all, Menu.FIRST, R.string.download); mi.setIcon(R.drawable.ic_download_light); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); removeActionIfNecessary(menu, mi.getItemId(), ConfigurableActionHelper.ACTION_NODE_DOWNLOAD); if (!(SessionUtils.getSession(activity) instanceof CloudSession)) { mi = menu.add(Menu.NONE, R.id.menu_workflow_review_attachments, Menu.FIRST + 500, R.string.process_start_review); mi.setIcon(R.drawable.ic_start_review); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); removeActionIfNecessary(menu, mi.getItemId(), ConfigurableActionHelper.ACTION_NODE_REVIEW); } } // SYNC if (SyncContentManager.getInstance(getActivity()).hasActivateSync(getAccount()) && !SyncContentManager.getInstance(getActivity()).isSynced(getAccount(), parentFolder)) { createMenu = menu.addSubMenu(Menu.NONE, R.id.menu_action_sync_group, Menu.FIRST, R.string.sync); createMenu.setIcon(R.drawable.ic_sync_light); createMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); removeActionIfNecessary(menu, createMenu.getItem().getItemId(), ConfigurableActionHelper.ACTION_NODE_SYNC); createMenu.add(Menu.NONE, R.id.menu_action_sync_group_sync, Menu.FIRST + 1, R.string.sync); createMenu.add(Menu.NONE, R.id.menu_action_sync_group_unsync, Menu.FIRST + 2, R.string.unsync); } // FAVORITES createMenu = menu.addSubMenu(Menu.NONE, R.id.menu_action_favorite_group, Menu.FIRST + 135, R.string.favorite); createMenu.setIcon(R.drawable.ic_favorite_light); createMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); removeActionIfNecessary(menu, createMenu.getItem().getItemId(), ConfigurableActionHelper.ACTION_NODE_FAVORITE); createMenu.add(Menu.NONE, R.id.menu_action_favorite_group_favorite, Menu.FIRST + 1, R.string.favorite); createMenu.add(Menu.NONE, R.id.menu_action_favorite_group_unfavorite, Menu.FIRST + 2, R.string.unfavorite); // LIKE AlfrescoSession alfSession = SessionUtils.getSession(activity); if (alfSession != null && alfSession.getRepositoryInfo() != null && alfSession.getRepositoryInfo().getCapabilities() != null && alfSession.getRepositoryInfo().getCapabilities().doesSupportLikingNodes()) { createMenu = menu.addSubMenu(Menu.NONE, R.id.menu_action_like_group, Menu.FIRST + 150, R.string.like); createMenu.setIcon(R.drawable.ic_like); createMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); removeActionIfNecessary(menu, createMenu.getItem().getItemId(), ConfigurableActionHelper.ACTION_NODE_LIKE); createMenu.add(Menu.NONE, R.id.menu_action_like_group_like, Menu.FIRST + 1, R.string.like); createMenu.add(Menu.NONE, R.id.menu_action_like_group_unlike, Menu.FIRST + 2, R.string.unlike); } if (parentFolder != null && ConfigurableActionHelper.isVisible(getActivity(), getAccount(), getSession(), parentFolder, ConfigurableActionHelper.ACTION_NODE_DELETE)) { mi = menu.add(Menu.NONE, R.id.menu_action_delete, Menu.FIRST + 1000, R.string.delete); mi.setIcon(R.drawable.ic_delete); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); removeActionIfNecessary(menu, mi.getItemId(), ConfigurableActionHelper.ACTION_NODE_DELETE); } }
From source file:com.keithandthegirl.ui.activity.GuestsDashboardFragment.java
@Override @TargetApi(11)/* w ww . j a va 2 s. c om*/ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { Log.v(TAG, "onCreateOptionsMenu : enter"); super.onCreateOptionsMenu(menu, inflater); MenuItem refresh = menu.add(Menu.NONE, REFRESH_ID, Menu.NONE, getResources().getString(R.string.menu_refresh)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { refresh.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } MenuItem mostRecent = menu.add(Menu.NONE, MOST_RECENT_ID, Menu.NONE, getResources().getString(R.string.menu_most_recent)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { mostRecent.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); } MenuItem topCount = menu.add(Menu.NONE, TOP_COUNT_ID, Menu.NONE, getResources().getString(R.string.menu_top_count)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { topCount.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); } MenuItem name = menu.add(Menu.NONE, NAME_ID, Menu.NONE, getResources().getString(R.string.menu_name)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { name.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); } Log.v(TAG, "onCreateOptionsMenu : exit"); }
From source file:info.guardianproject.otr.app.im.app.ContactListActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getSupportMenuInflater(); inflater.inflate(R.menu.contact_list_menu, menu); mSearchView = SearchViewCompat.newSearchView(this); if (mSearchView != null) { MenuItem item = menu.add("Search").setIcon(android.R.drawable.ic_menu_search) .setActionView(mSearchView); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); SearchViewCompat.setOnQueryTextListener(mSearchView, new SearchViewCompat.OnQueryTextListenerCompat() { @Override/* w w w . j a v a 2 s .co m*/ public boolean onQueryTextChange(String newText) { mFilterView.doFilter(newText); return true; } @Override public boolean onQueryTextSubmit(String query) { mFilterView.doFilter(query); return true; } }); } return true; }