List of usage examples for android.view Menu clear
public void clear();
From source file:pt.aptoide.backupapps.Aptoide.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { menu.clear(); currentAppsList = EnumAppsLists.reverseOrdinal(appsListPager.getCurrentItem()); switch (currentAppsList) { case RESTORE: // menu.add(Menu.NONE, EnumOptionsMenu.DELETE.ordinal(), EnumOptionsMenu.DELETE.ordinal(), R.string.delete) // .setIcon(R.drawable.ic_menu_close_clear_cancel); break;/*from w w w. j av a 2 s .c o m*/ case BACKUP: menu.add(Menu.NONE, EnumOptionsMenu.UNINSTALL.ordinal(), EnumOptionsMenu.UNINSTALL.ordinal(), R.string.uninstall).setIcon(android.R.drawable.ic_menu_delete); break; // case Updates: // menu.add(Menu.NONE, EnumOptionsMenu.UPDATE_ALL.ordinal(), EnumOptionsMenu.UPDATE_ALL.ordinal(), R.string.update_all) // .setIcon(R.drawable.ic_menu_refresh); // menu.add(Menu.NONE, EnumOptionsMenu.DISPLAY_OPTIONS.ordinal(), EnumOptionsMenu.DISPLAY_OPTIONS.ordinal(), R.string.display_options) // .setIcon(R.drawable.ic_menu_filter); // break; default: break; } // menu.add(Menu.NONE, EnumOptionsMenu.MANAGE_REPO.ordinal(), EnumOptionsMenu.MANAGE_REPO.ordinal(), R.string.manage_repos) // .setIcon(R.drawable.ic_menu_archive); // menu.add(Menu.NONE,EnumOptionsMenu.SCHEDULED_DOWNLOADS.ordinal(),EnumOptionsMenu.SCHEDULED_DOWNLOADS.ordinal(),R.string.scheduled_downloads) // .setIcon(R.drawable.ic_menu_clock); // menu.add(Menu.NONE, EnumOptionsMenu.SEARCH_MENU.ordinal(),EnumOptionsMenu.SEARCH_MENU.ordinal(),R.string.menu_search) // .setIcon(android.R.drawable.ic_menu_search); menu.add(Menu.NONE, EnumOptionsMenu.DISPLAY_OPTIONS.ordinal(), EnumOptionsMenu.DISPLAY_OPTIONS.ordinal(), R.string.display_options).setIcon(android.R.drawable.ic_menu_sort_by_size); menu.add(Menu.NONE, EnumOptionsMenu.UN_SELECT_ALL.ordinal(), EnumOptionsMenu.UN_SELECT_ALL.ordinal(), R.string.un_select_all).setIcon(android.R.drawable.ic_menu_add); menu.add(Menu.NONE, EnumOptionsMenu.ABOUT.ordinal(), EnumOptionsMenu.ABOUT.ordinal(), R.string.about) .setIcon(android.R.drawable.ic_menu_help); menu.add(Menu.NONE, EnumOptionsMenu.SETTINGS.ordinal(), EnumOptionsMenu.SETTINGS.ordinal(), R.string.settings).setIcon(android.R.drawable.ic_menu_preferences); menu.add(Menu.NONE, EnumOptionsMenu.LOGIN.ordinal(), EnumOptionsMenu.LOGIN.ordinal(), R.string.login) .setIcon(android.R.drawable.ic_menu_edit); menu.add(Menu.NONE, EnumOptionsMenu.FOLLOW.ordinal(), EnumOptionsMenu.FOLLOW.ordinal(), R.string.social_networks).setIcon(android.R.drawable.ic_menu_share); return super.onCreateOptionsMenu(menu); }
From source file:github.daneren2005.dsub.fragments.SubsonicFragment.java
protected void recreateContextMenu(Menu menu) { List<MenuItem> menuItems = new ArrayList<MenuItem>(); for (int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); if (item.isVisible()) { menuItems.add(item);//from w ww.j a va 2 s . c o m } } menu.clear(); for (int i = 0; i < menuItems.size(); i++) { MenuItem item = menuItems.get(i); menu.add(tag, item.getItemId(), Menu.NONE, item.getTitle()); } }
From source file:org.thoughtcrime.securesms.conversation.ConversationActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { MenuInflater inflater = this.getMenuInflater(); menu.clear(); if (isSecureText) { if (recipient.getExpireMessages() > 0) { inflater.inflate(R.menu.conversation_expiring_on, menu); final MenuItem item = menu.findItem(R.id.menu_expiring_messages); final View actionView = MenuItemCompat.getActionView(item); final TextView badgeView = actionView.findViewById(R.id.expiration_badge); badgeView.setText(//from w w w. java 2s . c o m ExpirationUtil.getExpirationAbbreviatedDisplayValue(this, recipient.getExpireMessages())); actionView.setOnClickListener(v -> onOptionsItemSelected(item)); } else { inflater.inflate(R.menu.conversation_expiring_off, menu); } } if (isSingleConversation()) { if (isSecureText) inflater.inflate(R.menu.conversation_callable_secure, menu); else inflater.inflate(R.menu.conversation_callable_insecure, menu); } else if (isGroupConversation()) { inflater.inflate(R.menu.conversation_group_options, menu); if (!isPushGroupConversation()) { inflater.inflate(R.menu.conversation_mms_group_options, menu); if (distributionType == ThreadDatabase.DistributionTypes.BROADCAST) { menu.findItem(R.id.menu_distribution_broadcast).setChecked(true); } else { menu.findItem(R.id.menu_distribution_conversation).setChecked(true); } } else if (isActiveGroup()) { inflater.inflate(R.menu.conversation_push_group_options, menu); } } inflater.inflate(R.menu.conversation, menu); if (isSingleConversation() && isSecureText) { inflater.inflate(R.menu.conversation_secure, menu); } else if (isSingleConversation()) { inflater.inflate(R.menu.conversation_insecure, menu); } if (recipient != null && recipient.isMuted()) inflater.inflate(R.menu.conversation_muted, menu); else inflater.inflate(R.menu.conversation_unmuted, menu); if (isSingleConversation() && getRecipient().getContactUri() == null) { inflater.inflate(R.menu.conversation_add_to_contacts, menu); } if (recipient != null && recipient.isLocalNumber()) { if (isSecureText) menu.findItem(R.id.menu_call_secure).setVisible(false); else menu.findItem(R.id.menu_call_insecure).setVisible(false); MenuItem muteItem = menu.findItem(R.id.menu_mute_notifications); if (muteItem != null) { muteItem.setVisible(false); } } searchViewItem = menu.findItem(R.id.menu_search); SearchView searchView = (SearchView) searchViewItem.getActionView(); SearchView.OnQueryTextListener queryListener = new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { searchViewModel.onQueryUpdated(query, threadId); searchNav.showLoading(); fragment.onSearchQueryUpdated(query); return true; } @Override public boolean onQueryTextChange(String query) { searchViewModel.onQueryUpdated(query, threadId); searchNav.showLoading(); fragment.onSearchQueryUpdated(query); return true; } }; searchViewItem.setOnActionExpandListener(new MenuItem.OnActionExpandListener() { @Override public boolean onMenuItemActionExpand(MenuItem item) { searchView.setOnQueryTextListener(queryListener); searchViewModel.onSearchOpened(); searchNav.setVisibility(View.VISIBLE); searchNav.setData(0, 0); inputPanel.setVisibility(View.GONE); for (int i = 0; i < menu.size(); i++) { if (!menu.getItem(i).equals(searchViewItem)) { menu.getItem(i).setVisible(false); } } return true; } @Override public boolean onMenuItemActionCollapse(MenuItem item) { searchView.setOnQueryTextListener(null); searchViewModel.onSearchClosed(); searchNav.setVisibility(View.GONE); inputPanel.setVisibility(View.VISIBLE); fragment.onSearchQueryUpdated(null); invalidateOptionsMenu(); return true; } }); super.onPrepareOptionsMenu(menu); return true; }
From source file:cm.aptoide.pt.MainActivity.java
@Override public boolean onPrepareOptionsMenu(cm.aptoide.com.actionbarsherlock.view.Menu menu) { menu.clear(); // menu.add(Menu.NONE, EnumOptionsMenu.SEARCH.ordinal(), // EnumOptionsMenu.SEARCH.ordinal(), "Search") // .setIcon(R.drawable.ic_search) // .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | // MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); menu.add(Menu.NONE, EnumOptionsMenu.LOGIN.ordinal(), EnumOptionsMenu.LOGIN.ordinal(), R.string.my_account) .setIcon(android.R.drawable.ic_menu_edit); menu.add(Menu.NONE, EnumOptionsMenu.DISPLAY_OPTIONS.ordinal(), EnumOptionsMenu.DISPLAY_OPTIONS.ordinal(), R.string.menu_display_options).setIcon(android.R.drawable.ic_menu_sort_by_size); menu.add(Menu.NONE, EnumOptionsMenu.SCHEDULED_DOWNLOADS.ordinal(), EnumOptionsMenu.SCHEDULED_DOWNLOADS.ordinal(), R.string.setting_schdwntitle) .setIcon(android.R.drawable.ic_menu_agenda); menu.add(Menu.NONE, EnumOptionsMenu.SETTINGS.ordinal(), EnumOptionsMenu.SETTINGS.ordinal(), R.string.settings_title_bar).setIcon(android.R.drawable.ic_menu_manage); if (ApplicationAptoide.PARTNERID == null) { // menu.add(Menu.NONE, EnumOptionsMenu.ABOUT.ordinal(), // EnumOptionsMenu.ABOUT.ordinal(), R.string.about).setIcon( // android.R.drawable.ic_menu_help); menu.add(Menu.NONE, EnumOptionsMenu.FOLLOW.ordinal(), EnumOptionsMenu.FOLLOW.ordinal(), R.string.social_networks).setIcon(android.R.drawable.ic_menu_share); }//w ww. ja v a2 s . co m menu.add(Menu.NONE, EnumOptionsMenu.DOWNLOADMANAGER.ordinal(), EnumOptionsMenu.DOWNLOADMANAGER.ordinal(), R.string.download_manager).setIcon(android.R.drawable.ic_menu_save); return super.onPrepareOptionsMenu(menu); }
From source file:com.hichinaschool.flashcards.anki.DeckPicker.java
@Override public boolean onMenuOpened(int featureId, Menu menu) { if (mInvalidateMenu) { if (menu != null) { menu.clear(); onCreateOptionsMenu(menu);//from w w w .j a va 2s .c o m } mInvalidateMenu = false; } return super.onMenuOpened(featureId, menu); }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { menu.clear(); menu.add(0, INSTALL, 0, "Install Roms").setIcon(android.R.drawable.ic_menu_agenda); menu.add(0, DELETE, 0, "Delete Machine").setIcon(android.R.drawable.ic_menu_close_clear_cancel); menu.add(0, EXPORT, 0, "Export Machines").setIcon(android.R.drawable.ic_menu_save); menu.add(0, IMPORT, 0, "Import Machines").setIcon(android.R.drawable.ic_menu_send); menu.add(0, HELP, 0, "Help").setIcon(android.R.drawable.ic_menu_help); menu.add(0, CHANGELOG, 0, "Changelog").setIcon(android.R.drawable.ic_menu_help); menu.add(0, LICENSE, 0, "License").setIcon(android.R.drawable.ic_menu_help); menu.add(0, QUIT, 0, "Exit").setIcon(android.R.drawable.ic_lock_power_off); return true;//w w w . j a v a 2 s. c o m }
From source file:org.telegram.ui.ChatActivity.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { menu.clear(); inflater.inflate(R.menu.chat_menu, menu); if (currentEncryptedChat != null && !(currentEncryptedChat instanceof TLRPC.TL_encryptedChat) || currentChat != null && (currentChat instanceof TLRPC.TL_chatForbidden || currentChat.left)) { SupportMenuItem item = (SupportMenuItem) menu.findItem(R.id.chat_menu_attach); item.setVisible(false);/*from w w w .j a v a 2 s. co m*/ } SupportMenuItem avatarItem = (SupportMenuItem) menu.findItem(R.id.chat_menu_avatar); View avatarLayout = avatarItem.getActionView(); avatarImageView = (BackupImageView) avatarLayout.findViewById(R.id.chat_avatar_image); avatarImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (parentActivity == null) { return; } if (currentUser != null) { UserProfileActivity fragment = new UserProfileActivity(); Bundle args = new Bundle(); args.putInt("user_id", currentUser.id); if (currentEncryptedChat != null) { args.putLong("dialog_id", dialog_id); } fragment.setArguments(args); ((ApplicationActivity) parentActivity).presentFragment(fragment, "user_" + currentUser.id, swipeOpening); } else if (currentChat != null) { if (info != null) { if (info instanceof TLRPC.TL_chatParticipantsForbidden) { return; } NotificationCenter.Instance.addToMemCache(5, info); } if (currentChat.participants_count == 0 || currentChat.left || currentChat instanceof TLRPC.TL_chatForbidden) { return; } ChatProfileActivity fragment = new ChatProfileActivity(); Bundle args = new Bundle(); args.putInt("chat_id", currentChat.id); fragment.setArguments(args); ((ApplicationActivity) parentActivity).presentFragment(fragment, "chat_" + currentChat.id, swipeOpening); } } }); TLRPC.FileLocation photo = null; int placeHolderId = 0; if (currentUser != null) { if (currentUser.photo != null) { photo = currentUser.photo.photo_small; } placeHolderId = Utilities.getUserAvatarForId(currentUser.id); } else if (currentChat != null) { if (currentChat.photo != null) { photo = currentChat.photo.photo_small; } placeHolderId = Utilities.getGroupAvatarForId(currentChat.id); } avatarImageView.setImage(photo, "50_50", placeHolderId); }
From source file:org.brandroid.openmanager.activities.OpenExplorer.java
public boolean onCreateOptionsMenu(Menu menu, boolean fromSystem) { MenuUtils.scanMenuShortcuts(menu, getMenuInflater()); //mActionBarHelper.onCreateOptionsMenu(menu); OpenFragment frag = getSelectedFragment(); //if(menu == null) menu = new MenuBuilder(this); menu.clear(); if (DEBUG)// w w w.ja v a 2 s .com Logger.LogDebug("OpenExplorer.onCreateOptionsMenu(" + menu + "," + fromSystem + ")"); //getMenuInflater().inflate(R.menu.global_top, menu); if (frag != null) // && frag.hasOptionsMenu()) frag.onCreateOptionsMenu(menu, getMenuInflater()); getMenuInflater().inflate(R.menu.global, menu); if (!USE_PRETTY_MENUS) { MenuUtils.setMenuVisible(menu, false, R.id.menu_more); return true; } /* if(!BEFORE_HONEYCOMB) for(int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); if(item.getActionView() == null) item.setActionView(makeMenuButton(item, null)); } */ if (mOptsMenu == null) mOptsMenu = new MenuBuilder(this); mOptsMenu.clear(); mOptsMenu.setQwertyMode(true); MenuUtils.transferMenu(menu, mOptsMenu, false); MenuUtils.setMenuVisible(mOptsMenu, false, R.id.menu_more); MenuUtils.hideMenuGrandChildren(mOptsMenu); if (!USE_PRETTY_MENUS) { handleMoreMenu(menu, false); MenuUtils.fillSubMenus(menu, getMenuInflater()); } else { // if(isGTV()) { if (isGTV()) { handleMoreMenu(mMainMenu, true, 6); //*/ if (!menu.equals(mMainMenu)) menu.clear(); else MenuUtils.fillSubMenus(menu, getMenuInflater()); } else { handleMoreMenu(menu, true); if (!menu.equals(mMainMenu) && !getResources().getBoolean(R.bool.allow_split_actionbar)) MenuUtils.setMenuVisible(menu, false); //else fillSubMenus(menu, getMenuInflater()); } } //else MenuUtils.setMenuVisible(menu, false, R.id.menu_more); /*else { fillSubMenus(mMainMenu, getMenuInflater()); handleMoreMenu(menu, false); }*/ return true; }
From source file:com.android.mms.ui.ComposeMessageActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); menu.clear(); if (mSendDiscreetMode && !mForwardMessageMode) { // When we're in send-a-single-message mode from the lock screen, don't show // any menus. return true; }/*from w w w.jav a 2s . c om*/ if (isRecipientCallable()) { MenuItem item = menu.add(0, MENU_CALL_RECIPIENT, 0, R.string.menu_call) .setIcon(R.drawable.ic_menu_call_holo_light).setTitle(R.string.menu_call); if (!isRecipientsEditorVisible()) { // If we're not composing a new message, show the call icon in the actionbar item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); } } if (MmsConfig.getMmsEnabled() && mIsSmsEnabled) { if (!isSubjectEditorVisible()) { menu.add(0, MENU_ADD_SUBJECT, 0, R.string.add_subject).setIcon(R.drawable.ic_menu_edit); } if (!mWorkingMessage.hasAttachment()) { menu.add(0, MENU_ADD_ATTACHMENT, 0, R.string.add_attachment) .setIcon(R.drawable.ic_menu_attachment_holo_light).setTitle(R.string.add_attachment) .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); // add to actionbar } } menu.add(0, MENU_ADD_TEMPLATE, 0, R.string.template_insert).setIcon(android.R.drawable.ic_menu_add) .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); if (isPreparedForSending() && mIsSmsEnabled) { menu.add(0, MENU_SEND, 0, R.string.send).setIcon(android.R.drawable.ic_menu_send); } if (!mWorkingMessage.hasSlideshow() && mIsSmsEnabled && mEnableEmoticons) { menu.add(0, MENU_INSERT_SMILEY, 0, R.string.menu_insert_smiley).setIcon(R.drawable.ic_menu_emoticons); } if (getRecipients().size() > 1) { menu.add(0, MENU_GROUP_PARTICIPANTS, 0, R.string.menu_group_participants); } if (mMsgListAdapter.getCount() > 0 && mIsSmsEnabled) { // Removed search as part of b/1205708 //menu.add(0, MENU_SEARCH, 0, R.string.menu_search).setIcon( // R.drawable.ic_menu_search); Cursor cursor = mMsgListAdapter.getCursor(); if ((null != cursor) && (cursor.getCount() > 0)) { menu.add(0, MENU_DELETE_THREAD, 0, R.string.delete_thread) .setIcon(android.R.drawable.ic_menu_delete); } } else if (mIsSmsEnabled) { menu.add(0, MENU_DISCARD, 0, R.string.discard).setIcon(android.R.drawable.ic_menu_delete); } buildAddAddressToContactMenuItem(menu); // Add to Blacklist item (if enabled) and we are running on CyanogenMod // This allows the app to be run on non-blacklist enabled roms (including Stock) if (MessageUtils.isCyanogenMod(this)) { if (BlacklistUtils.isBlacklistEnabled(this)) { menu.add(0, MENU_ADD_TO_BLACKLIST, 0, R.string.add_to_blacklist) .setIcon(R.drawable.ic_block_message_holo_dark) .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } } if (mConversation.getThreadId() > 0) { menu.add(0, MENU_CONVERSATION_OPTIONS, 0, R.string.menu_conversation_options); } menu.add(0, MENU_PREFERENCES, 0, R.string.menu_preferences).setIcon(android.R.drawable.ic_menu_preferences); if (LogTag.DEBUG_DUMP) { menu.add(0, MENU_DEBUG_DUMP, 0, R.string.menu_debug_dump); } return true; }
From source file:com.xmobileapp.rockplayer.RockPlayer.java
/******************************************* * /*from w w w . j a v a2s .c om*/ * Create Menu * *******************************************/ public boolean onPrepareOptionsMenu(Menu menu) { /* * Initialize clean menu */ super.onPrepareOptionsMenu(menu); menu.clear(); /* * Add menu items */ if (this.SHUFFLE) menu.add(0, 0, 0, "Suffle Off"); else menu.add(0, 0, 0, "Shuffle On"); menu.add(0, 1, 1, "Search"); menu.add(0, 5, 5, "Share"); menu.add(0, 3, 3, "Get Art"); menu.add(0, 4, 4, "Concerts"); menu.add(0, 6, 6, "Playlists"); menu.add(0, 7, 7, "Preferences"); menu.add(0, 8, 8, "Help"); menu.add(0, 2, 2, "Exit"); /* * Add menu icons */ (menu.findItem(0)).setIcon(R.drawable.ic_menu_shuffle); (menu.findItem(3)).setIcon(R.drawable.ic_menu_music_library); (menu.findItem(5)).setIcon(android.R.drawable.ic_menu_share); (menu.findItem(1)).setIcon(android.R.drawable.ic_menu_search); //(menu.findItem(3)).setIcon(android.R.drawable.ic_menu_slideshow); (menu.findItem(4)).setIcon(android.R.drawable.ic_menu_today); (menu.findItem(6)).setIcon(R.drawable.ic_mp_current_playlist_btn); (menu.findItem(7)).setIcon(android.R.drawable.ic_menu_preferences); (menu.findItem(8)).setIcon(android.R.drawable.ic_menu_help); (menu.findItem(2)).setIcon(android.R.drawable.ic_menu_close_clear_cancel); //(menu.findItem(6)).setIcon(android.R.drawable.ic_menu_preferences); return true; }