List of usage examples for android.view MenuItem setVisible
public MenuItem setVisible(boolean visible);
From source file:com.fastbootmobile.encore.app.MainActivity.java
@Override public boolean onCreateOptionsMenu(final Menu menu) { if (!mNavigationDrawerFragment.isDrawerOpen()) { if ((mCurrentFragmentIndex + 1) != SECTION_AUTOMIX) { // Only show items in the action bar relevant to this screen // if the drawer is not showing. Otherwise, let the drawer // decide what to show in the action bar. getMenuInflater().inflate(R.menu.main, menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); mSearchView = (SearchView) menu.findItem(R.id.action_search).getActionView(); mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); mSearchView.setIconifiedByDefault(true); mSearchView.setQueryRefinementEnabled(true); mSearchView.setSubmitButtonEnabled(true); if (mCurrentFragmentIndex + 1 == SECTION_LISTEN_NOW) { menu.removeItem(R.id.action_search); }//from w w w.jav a2 s. co m mSearchView.setOnSearchClickListener(new View.OnClickListener() { @Override public void onClick(View v) { menu.findItem(R.id.action_cast).setVisible(false); mNavigationDrawerFragment.setDrawerIndicatorEnabled(false); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mSearchView.requestFocus(); mToolbar.setBackgroundColor(getResources().getColor(R.color.primary)); } }); mSearchView.setOnCloseListener(new SearchView.OnCloseListener() { @Override public boolean onClose() { if (Utils.hasJellyBeanMR1()) { MenuItem item = menu.findItem(R.id.action_cast); if (item != null) { item.setVisible(true); } } getSupportActionBar().setDisplayHomeAsUpEnabled(false); mNavigationDrawerFragment.setDrawerIndicatorEnabled(true); return false; } }); // Setup cast button on 4.2+ MenuItem castMenu = menu.findItem(R.id.action_cast); if (Utils.hasJellyBeanMR1()) { MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider) MenuItemCompat .getActionProvider(castMenu); mediaRouteActionProvider.setRouteSelector(mCastModule.getSelector()); castMenu.setVisible(true); } else { Log.w(TAG, "Api too low to show cast action"); castMenu.setVisible(false); } // Offline mode mOfflineMenuItem = menu.findItem(R.id.action_offline_mode); ProviderAggregator aggregator = ProviderAggregator.getDefault(); if (aggregator.hasNetworkConnectivity()) { mOfflineMenuItem.setChecked(aggregator.isOfflineMode()); } else { mOfflineMenuItem.setEnabled(false); } } restoreActionBar(); return true; } return super.onCreateOptionsMenu(menu); }
From source file:cx.ring.fragments.SmartListFragment.java
/** * Handles the visibility of some menus to hide / show the overflow menu * * @param menu the menu containing the menuitems we need to access * @param visible true to display the overflow menu, false otherwise *//*from w w w. ja v a 2 s . c om*/ private void setOverflowMenuVisible(final Menu menu, boolean visible) { if (null != menu) { MenuItem scanQrMenuItem = menu.findItem(R.id.menu_scan_qr); MenuItem clearHistoryMenuItem = menu.findItem(R.id.menu_clear_history); if (null != scanQrMenuItem) { scanQrMenuItem.setVisible(visible); } if (null != clearHistoryMenuItem) { clearHistoryMenuItem.setVisible(visible); } } }
From source file:me.barrasso.android.volume.activities.ConfigurationActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { if (!BuildConfig.DEBUG) { MenuItem sendLogsItem = menu.findItem(R.id.action_send_logs); if (sendLogsItem != null) { sendLogsItem.setVisible(false); }/*w ww . j av a2 s. c o m*/ } return true; }
From source file:com.dycode.jepretstory.mediachooser.activity.BucketHomeFragmentActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_home, menu); MenuItem cameraItem = menu.findItem(R.id.menuCamera); if (!MediaChooserConstants.showCameraVideo) { cameraItem.setVisible(false); }// w ww . j a v a 2 s .c o m this.mMenu = menu; setCurrentMode(MediaType.IMAGE); // init if (MediaChooserConstants.showImage) { setCurrentMode(MediaType.IMAGE); } else { setCurrentMode(MediaType.VIDEO); } return super.onCreateOptionsMenu(menu); }
From source file:com.granita.tasks.TaskListActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.task_list_activity_menu, menu); // restore menu state MenuItem item = menu.findItem(R.id.menu_alarms); if (item != null) { item.setChecked(AlarmBroadcastReceiver.getAlarmPreference(this)); }/*from w w w. jav a2s . co m*/ // search setupSearch(menu); //customs start SharedPreferences sharedPref = getSharedPreferences("localPreferences", Context.MODE_PRIVATE); if (sharedPref.getBoolean(getString(R.string.HIDE_AD_BOOLEAN), false)) { //remove all ads MenuItem removeAdItem = menu.findItem(R.id.removeads); removeAdItem.setVisible(false); } else { MenuItem removeAdItem = menu.findItem(R.id.removeads); removeAdItem.setVisible(true); } //custom end return true; }
From source file:com.joeyturczak.jtscanner.ui.ScannerFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); MenuItem menuItem = menu.findItem(R.id.action_save_spreadsheet); menuItem.setVisible(false); }
From source file:com.terracom.mumbleclient.app.QRPushToTalkActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { MenuItem disconnectButton = menu.findItem(R.id.action_disconnect); try {//from ww w . ja v a 2 s. c o m disconnectButton.setVisible(mService != null && mService.isConnected()); } catch (RemoteException e) { e.printStackTrace(); } // Color the action bar icons to the primary text color of the theme. int foregroundColor = getSupportActionBar().getThemedContext() .obtainStyledAttributes(new int[] { android.R.attr.textColor }).getColor(0, -1); for (int x = 0; x < menu.size(); x++) { MenuItem item = menu.getItem(x); if (item.getIcon() != null) { Drawable icon = item.getIcon().mutate(); // Mutate the icon so that the color filter is exclusive to the action bar icon.setColorFilter(foregroundColor, PorterDuff.Mode.MULTIPLY); } } return super.onPrepareOptionsMenu(menu); }
From source file:org.bohrmeista.chan.ui.activity.BoardActivity.java
private void setMenuItemEnabled(MenuItem item, boolean enabled) { if (item != null) { item.setVisible(enabled); item.setEnabled(enabled);/*from ww w . j a va 2s .c o m*/ } }
From source file:com.morlunk.mumbleclient.app.PlumbleActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { MenuItem disconnectButton = menu.findItem(R.id.action_disconnect); disconnectButton.setVisible(mService != null && mService.isSynchronized()); // Color the action bar icons to the primary text color of the theme. int foregroundColor = getSupportActionBar().getThemedContext() .obtainStyledAttributes(new int[] { android.R.attr.textColor }).getColor(0, -1); for (int x = 0; x < menu.size(); x++) { MenuItem item = menu.getItem(x); if (item.getIcon() != null) { Drawable icon = item.getIcon().mutate(); // Mutate the icon so that the color filter is exclusive to the action bar icon.setColorFilter(foregroundColor, PorterDuff.Mode.MULTIPLY); }/*from w w w . j a va 2s. com*/ } return super.onPrepareOptionsMenu(menu); }
From source file:com.maskyn.fileeditorpro.activity.SelectFileActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { // menu items MenuItem imSetAsWorkingFolder = menu.findItem(R.id.im_set_as_working_folder); MenuItem imIsWorkingFolder = menu.findItem(R.id.im_is_working_folder); MenuItem imSelectFolder = menu.findItem(R.id.im_select_folder); if (imSetAsWorkingFolder != null) { // set the imSetAsWorkingFolder visible only if the two folder dont concide imSetAsWorkingFolder .setVisible(!currentFolder.equals(PreferenceHelper.getWorkingFolder(SelectFileActivity.this))); }/* w w w.j a va 2s . c om*/ if (imIsWorkingFolder != null) { // set visible is the other is invisible imIsWorkingFolder.setVisible(!imSetAsWorkingFolder.isVisible()); } if (imSelectFolder != null) { imSelectFolder.setVisible(!wantAFile); } return super.onPrepareOptionsMenu(menu); }