List of usage examples for android.view MenuItem setVisible
public MenuItem setVisible(boolean visible);
From source file:bbct.android.common.activity.BaseballCardList.java
@Override public void onPrepareOptionsMenu(Menu menu) { Log.d(TAG, "onPrepareOptionsMenu()"); MenuItem filter = menu.findItem(R.id.filter_menu); MenuItem clearFilter = menu.findItem(R.id.clear_filter_menu); if (this.filterParams == null) { filter.setVisible(true); filter.setEnabled(true);/*from w w w . j av a 2s. c om*/ clearFilter.setVisible(false); clearFilter.setEnabled(false); } else { filter.setVisible(false); filter.setEnabled(false); clearFilter.setVisible(true); clearFilter.setEnabled(true); } }
From source file:com.foodie.app.Activity.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.home_actions, menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); MenuItem searchMenuItem = menu.findItem(R.id.id_action_search); SearchView searchView = null;// ww w .ja v a 2 s. co m if (searchMenuItem != null) { searchView = (SearchView) searchMenuItem.getActionView(); } if (searchView != null) { searchView.setSearchableInfo(searchManager.getSearchableInfo(MainActivity.this.getComponentName())); } SearchView.SearchAutoComplete searchAutoComplete = (SearchView.SearchAutoComplete) searchView .findViewById(android.support.v7.appcompat.R.id.search_src_text); searchAutoComplete.setHintTextColor(Color.WHITE); searchAutoComplete.setTextColor(Color.WHITE); searchAutoComplete.setHint("?,,"); //? searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { //Toast.makeText(MainActivity.this,""+query,Toast.LENGTH_SHORT).show(); Intent intent = new Intent(MainActivity.this, SearchResultsActivity.class); intent.putExtra("query", query); startActivity(intent); return true; } @Override public boolean onQueryTextChange(String newText) { //Toast.makeText(MainActivity.this,""+newText,Toast.LENGTH_SHORT).show(); return false; } }); //?? View searchplate = (View) searchView.findViewById(android.support.v7.appcompat.R.id.search_plate); //searchplate.setBackgroundResource(R.drawable.ic_search_white_24dp); ImageView searchCloseIcon = (ImageView) searchView .findViewById(android.support.v7.appcompat.R.id.search_close_btn); searchCloseIcon.setImageResource(R.drawable.ic_close_white_24dp); ImageView voiceIcon = (ImageView) searchView .findViewById(android.support.v7.appcompat.R.id.search_voice_btn); voiceIcon.setImageResource(R.drawable.ic_settings_voice_white_24dp); //searchView.setSubmitButtonEnabled(true); // to enable submit button ImageView b = (ImageView) searchView.findViewById(android.support.v7.appcompat.R.id.search_button); b.setImageResource(R.drawable.ic_search_white_24dp); //to change submit button icon ImageView searchIcon = (ImageView) searchView .findViewById(android.support.v7.appcompat.R.id.search_mag_icon); searchIcon.setImageResource(R.drawable.ic_search_white_24dp); switch (currentTab) { case 0: MenuItem miMap = menu.findItem(R.id.id_action_map); miMap.setVisible(false); break; case 1: MenuItem miSearch = menu.findItem(R.id.id_action_search); miSearch.setVisible(false); break; case 2: MenuItem mi1 = menu.findItem(R.id.id_action_map); mi1.setVisible(false); MenuItem mi2 = menu.findItem(R.id.id_action_search); mi2.setVisible(false); case 3: MenuItem mi3 = menu.findItem(R.id.id_action_map); mi3.setVisible(false); MenuItem mi4 = menu.findItem(R.id.id_action_search); mi4.setVisible(false); break; default: break; } return true; }
From source file:com.benlinskey.greekreference.lexicon.LexiconDetailActivity.java
/** * Sets the Lexicon Favorite icon to the appropriate state based on the currently selected * lexicon entry./*from w w w . j av a 2 s .c o m*/ * @param menu the {@code Menu} containing the Favorite icon */ private void setLexiconFavoriteIcon(Menu menu) { MenuItem addFavorite = menu.findItem(R.id.action_add_favorite); MenuItem removeFavorite = menu.findItem(R.id.action_remove_favorite); // Hide both icons when no word is selected or the app is in one-pane mode. if (isFavorite(mLexiconId)) { addFavorite.setVisible(false); removeFavorite.setVisible(true); } else { addFavorite.setVisible(true); removeFavorite.setVisible(false); } }
From source file:com.aboveware.actionbar.honeycomb.ActionBarHelperHoneycomb.java
@Override public void setRefreshActionVisible(boolean show) { MenuItem menuItem = mOptionsMenu.findItem(R.id.menu_refresh); if (menuItem != null) { menuItem.setVisible(show); }/*w w w.jav a2 s. c o m*/ }
From source file:org.docrj.smartcard.reader.AppViewActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { // handle read-only apps if (mReadOnly) { MenuItem editMenuItem = menu.findItem(R.id.menu_edit_app); editMenuItem.setVisible(false); MenuItem delMenuItem = menu.findItem(R.id.menu_delete_app); delMenuItem.setVisible(false);//from w w w . java 2s.co m } return true; }
From source file:com.jefftharris.passwdsafe.sync.lib.SyncedFilesFragment.java
/** * Initialize the contents of the Activity's standard options menu *//*from w w w . j a v a2 s . c o m*/ @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.fragment_synced_files, menu); boolean parentEnabled = !TextUtils.equals(ProviderRemoteFile.PATH_SEPARATOR, itsPathId); MenuItem item = menu.findItem(R.id.menu_parent_dir); MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); item.setVisible(parentEnabled); super.onCreateOptionsMenu(menu, inflater); }
From source file:com.microsoft.mimickeralarm.appcore.AlarmListFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.menu_alarm_list, menu); MenuItem add = menu.findItem(R.id.action_add_alarm); add.setVisible(mShowAddButtonInToolbar); super.onCreateOptionsMenu(menu, inflater); }
From source file:ca.ualberta.cmput301w14t08.geochan.fragments.CustomLocationFragment.java
/** * Inflates the menu and adds any action bar items that are present. *//* w ww.j av a 2 s. c o m*/ @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { MenuItem item = menu.findItem(R.id.action_settings); item.setVisible(true); super.onCreateOptionsMenu(menu, inflater); }
From source file:com.google.samples.apps.iosched.navigation.AppNavigationViewAsDrawerImpl.java
private void createNavDrawerItems(NavigationModel.NavigationItemEnum[] items) { if (mNavigationView != null) { Menu menu = mNavigationView.getMenu(); for (int i = 0; i < items.length; i++) { MenuItem item = menu.findItem(items[i].getId()); if (item != null) { item.setVisible(true); item.setIcon(items[i].getIconResource()); item.setTitle(items[i].getTitleResource()); } else { LOGE(TAG,/* w ww. ja va 2s . c o m*/ "Menu Item for navigation item with title " + (items[i].getTitleResource() != 0 ? mActivity.getResources().getString(items[i].getTitleResource()) : "") + "not found"); } } mNavigationView.setNavigationItemSelectedListener(this); } }
From source file:com.trellmor.mocklocationpicture.MLPActivity.java
private void configureShareItem(MenuItem item, Uri uri, String mimeType) { if (uri != null && mimeType != null) { item.setVisible(true); ShareCompat.IntentBuilder shareIntent = ShareCompat.IntentBuilder.from(MLPActivity.this); shareIntent.setStream(uri);/* ww w. j av a 2 s. c om*/ shareIntent.setType(mimeType); ShareCompat.configureMenuItem(item, shareIntent); } else { item.setVisible(false); } }