List of usage examples for android.view MenuItem setVisible
public MenuItem setVisible(boolean visible);
From source file:com.nadmm.airports.FragmentBase.java
@Override public void onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); MenuItem refresh = menu.findItem(R.id.menu_refresh); refresh.setVisible(isRefreshable()); }
From source file:com.irateam.vkplayer.activities.ListActivity.java
public void performCheck(int position) { audioAdapter.toggleChecked(position); if (audioAdapter.getCheckedCount() > 0) { if (actionMode == null) { startActionMode(this); }/*from w w w. j ava 2 s . c om*/ actionMode.setTitle(String.valueOf(audioAdapter.getCheckedCount())); Menu menu = actionMode.getMenu(); MenuItem cacheItem = menu.findItem(R.id.action_cache); MenuItem removeFromCache = menu.findItem(R.id.action_remove_from_cache); if (audioAdapter.getCachedCheckedItems().size() > 0) { removeFromCache.setVisible(true); } else { removeFromCache.setVisible(false); } if (audioAdapter.getNotCachedItems().size() > 0) { cacheItem.setVisible(true); } else { cacheItem.setVisible(false); } } else { actionMode.finish(); } }
From source file:com.synox.android.ui.fragment.FileDetailFragment.java
/** * {@inheritDoc}/* ww w . j a v a 2 s .com*/ */ @Override public void onPrepareOptionsMenu(Menu menu) { menu.findItem(R.id.action_search).setVisible(false); menu.findItem(R.id.action_changeView).setVisible(false); super.onPrepareOptionsMenu(menu); if (mContainerActivity.getStorageManager() != null) { FileMenuFilter mf = new FileMenuFilter(getFile(), mContainerActivity.getStorageManager().getAccount(), mContainerActivity, getActivity()); mf.filter(menu); } // additional restriction for this fragment MenuItem item = menu.findItem(R.id.action_see_details); if (item != null) { item.setVisible(false); item.setEnabled(false); } // additional restriction for this fragment item = menu.findItem(R.id.action_move); if (item != null) { item.setVisible(false); item.setEnabled(false); } // additional restriction for this fragment item = menu.findItem(R.id.action_copy); if (item != null) { item.setVisible(false); item.setEnabled(false); } }
From source file:com.fastbootmobile.encore.app.AlbumActivity.java
@Override public boolean onCreateOptionsMenu(final Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.album, menu); // Keep in tune with the XML! final ProviderAggregator aggregator = ProviderAggregator.getDefault(); final Runnable updateMenuArtist = new Runnable() { @Override/*from www . j av a 2s. co m*/ public void run() { String artistRef = mActiveFragment.getArtist(); MenuItem item = menu.getItem(2); if (artistRef != null) { final Artist artist = aggregator.retrieveArtist(artistRef, mActiveFragment.getAlbum().getProvider()); if (artist != null) { item.setTitle(getString(R.string.more_from, artist.getName())); item.setVisible(true); } } else { // We don't have the tracks for that album yet, try again. mHandler.postDelayed(this, 1000); item.setVisible(false); } } }; updateMenuArtist.run(); return true; }
From source file:ca.ualberta.cmput301w14t08.geochan.fragments.ThreadViewFragment.java
/** * Sets up the menu for the fragment./*from ww w. j av a2 s . co m*/ * @param menu The Menu item for the fragment itself. * @param inflater The inflater for inflating the fragment's menu. */ @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { // Inflate the menu; this adds items to the action bar if it is present. inflater.inflate(R.menu.thread_view, menu); MenuItem item = menu.findItem(R.id.action_settings); item.setVisible(true); super.onCreateOptionsMenu(menu, inflater); }
From source file:com.dwdesign.tweetings.fragment.DMConversationFragment.java
@Override public boolean onItemLongClick(final AdapterView<?> adapter, final View view, final int position, final long id) { final Object tag = view.getTag(); if (tag instanceof DirectMessageConversationViewHolder) { final ParcelableDirectMessage dm = mSelectedDirectMessage = mAdapter.findItem(id); mPopupMenu = PopupMenu.getInstance(getActivity(), view); mPopupMenu.inflate(R.menu.action_direct_message); final Menu menu = mPopupMenu.getMenu(); final MenuItem view_profile_item = menu.findItem(MENU_VIEW_PROFILE); if (view_profile_item != null && dm != null) { view_profile_item.setVisible(dm.account_id != dm.sender_id); }//from w w w . j av a2 s .c o m mPopupMenu.setOnMenuItemClickListener(this); mPopupMenu.show(); return true; } return false; }
From source file:org.docrj.smartcard.reader.AppSelectActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { prepareOptionsMenu();// www. ja v a2 s .co m boolean drawerOpen = mNavDrawer.isOpen(); MenuItem item = menu.findItem(R.id.menu_add_app); item.setVisible(!drawerOpen); item = menu.findItem(R.id.menu_app_details); item.setVisible(!drawerOpen); mManualMenuItem.setVisible(!drawerOpen); item = menu.findItem(R.id.menu_share_msgs); item.setVisible(!drawerOpen); item = menu.findItem(R.id.menu_clear_msgs); item.setVisible(!drawerOpen); return true; }
From source file:org.digitalcampus.oppia.activity.DownloadMediaActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { menu.clear();//from www. j av a 2 s . c o m getMenuInflater().inflate(R.menu.missing_media_sortby, menu); MenuItem selectAll = menu.findItem(R.id.menu_select_all); if (selectAll != null) { selectAll.setVisible(missingMedia.size() != 0); } MenuItem sortBy = menu.findItem(R.id.menu_sort_by); if (sortBy != null) { sortBy.setVisible(missingMedia.size() != 0); sortBy.setTitle(isSortByCourse ? getString(R.string.menu_sort_by_filename) : getString(R.string.menu_sort_by_course)); } return true; }
From source file:org.cowboycoders.cyclisimo.BikeListActivity.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); getMenuInflater().inflate(R.menu.user_list_context_menu, menu); MenuItem deleteMenuItem = menu.findItem(R.id.list_context_menu_delete); deleteMenuItem.setVisible(isRecording()); MenuItem editMenuItem = menu.findItem(R.id.list_context_menu_edit); editMenuItem.setVisible(isRecording()); }
From source file:org.catrobat.catroid.ui.MainMenuActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { MenuItem logout = mainMenu.findItem(R.id.menu_logout); MenuItem login = mainMenu.findItem(R.id.menu_login); logout.setVisible(Utils.isUserLoggedIn(this)); login.setVisible(!Utils.isUserLoggedIn(this)); if (!BuildConfig.FEATURE_SCRATCH_CONVERTER_ENABLED) { mainMenu.removeItem(R.id.menu_scratch_converter); }/*w ww .j av a 2s .c om*/ return true; }