List of usage examples for android.view Menu removeItem
public void removeItem(int id);
From source file:com.gh4a.activities.IssueActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.issue_menu, menu); boolean authorized = Gh4Application.get().isAuthorized(); boolean isCreator = mIssue != null && authorized && ApiHelpers.loginEquals(mIssue.getUser(), Gh4Application.get().getAuthLogin()); boolean canOpenOrClose = mIssue != null && authorized && (isCreator || mIsCollaborator); if (!canOpenOrClose) { menu.removeItem(R.id.issue_close); menu.removeItem(R.id.issue_reopen); } else if (Constants.Issue.STATE_CLOSED.equals(mIssue.getState())) { menu.removeItem(R.id.issue_close); } else {//from ww w .ja v a2 s. c o m menu.removeItem(R.id.issue_reopen); } if (mIssue == null) { menu.removeItem(R.id.share); } return super.onCreateOptionsMenu(menu); }
From source file:com.fastbootmobile.encore.app.fragments.PlaylistViewFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.playlist, menu); if (mIsSpecialPlaylist) { // Remove some options not applicable to the special playlist mode menu.removeItem(R.id.menu_remove_duplicates); menu.removeItem(R.id.menu_remove_playlist); menu.removeItem(R.id.menu_rename_playlist); }//from w ww . j a va 2s . c o m }
From source file:com.master.metehan.filtereagle.ActivityMain.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); if (prefs.getBoolean("manage_system", false)) { menu.findItem(R.id.menu_app_user).setChecked(prefs.getBoolean("show_user", true)); menu.findItem(R.id.menu_app_system).setChecked(prefs.getBoolean("show_system", false)); } else {/*from w w w . ja va 2 s . c om*/ Menu submenu = menu.findItem(R.id.menu_filter).getSubMenu(); submenu.removeItem(R.id.menu_app_user); submenu.removeItem(R.id.menu_app_system); } menu.findItem(R.id.menu_app_nointernet).setChecked(prefs.getBoolean("show_nointernet", true)); menu.findItem(R.id.menu_app_disabled).setChecked(prefs.getBoolean("show_disabled", true)); String sort = prefs.getString("sort", "name"); if ("data".equals(sort)) menu.findItem(R.id.menu_sort_data).setChecked(true); else if ("uid".equals(sort)) menu.findItem(R.id.menu_sort_uid).setChecked(true); else menu.findItem(R.id.menu_sort_name).setChecked(true); return super.onPrepareOptionsMenu(menu); }
From source file:com.gh4a.fragment.PullRequestFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.pullrequest_menu, menu); Gh4Application app = Gh4Application.get(); boolean authorized = app.isAuthorized(); boolean isCreator = ApiHelpers.loginEquals(mPullRequest.getUser(), app.getAuthLogin()); boolean canOpenOrClose = authorized && (isCreator || mIsCollaborator); boolean canMerge = authorized && mIsCollaborator; if (!canOpenOrClose) { menu.removeItem(R.id.pull_close); menu.removeItem(R.id.pull_reopen); } else if (Constants.Issue.STATE_CLOSED.equals(mPullRequest.getState())) { menu.removeItem(R.id.pull_close); if (mPullRequest.isMerged()) { menu.findItem(R.id.pull_reopen).setEnabled(false); }// w w w. j av a2s. c o m } else { menu.removeItem(R.id.pull_reopen); } if (!canMerge) { menu.removeItem(R.id.pull_merge); } else if (mPullRequest.isMerged() || !mPullRequest.isMergeable()) { MenuItem mergeItem = menu.findItem(R.id.pull_merge); mergeItem.setEnabled(false); } super.onCreateOptionsMenu(menu, inflater); }
From source file:com.conferenceengineer.android.iosched.ui.HomeActivity.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override/* w w w . ja v a 2s.com*/ public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); mOptionsMenu = menu; getMenuInflater().inflate(R.menu.home, menu); MenuItem searchItem = menu.findItem(R.id.menu_search); if (searchItem != null && UIUtils.hasHoneycomb()) { SearchView searchView = (SearchView) searchItem.getActionView(); if (searchView != null) { SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setQueryRefinementEnabled(true); } } if (!getResources().getBoolean(R.bool.has_conference_feedback_enabled)) { menu.removeItem(R.id.menu_feedback); } return true; }
From source file:org.smilec.smile.ui.GeneralActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { // Adding Retake button to menu if (btResults.isEnabled()) { MenuItem item = menu.findItem(R.id.bt_retake); if (item == null) { menu.add(0, R.id.bt_retake, Menu.NONE, R.string.retake).setIcon(R.drawable.retake); }/*www . j a va2 s . c o m*/ } else { menu.removeItem(R.id.bt_retake); } return super.onPrepareOptionsMenu(menu); }
From source file:com.zhengde163.netguard.ActivityMain.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); if (prefs.getBoolean("manage_system", false)) { menu.findItem(R.id.menu_app_user).setChecked(prefs.getBoolean("show_user", true)); menu.findItem(R.id.menu_app_system).setChecked(prefs.getBoolean("show_system", false)); } else {// w w w .j av a2 s .co m Menu submenu = menu.findItem(R.id.menu_filter).getSubMenu(); submenu.removeItem(R.id.menu_app_user); submenu.removeItem(R.id.menu_app_system); } boolean nointernet = prefs.getBoolean("show_nointernet", true); boolean disabled = prefs.getBoolean("show_disabled", true); if (nointernet) menu.findItem(R.id.menu_app_nointernet).setIcon(R.drawable.checked); else menu.findItem(R.id.menu_app_nointernet).setIcon(R.drawable.check); if (disabled) menu.findItem(R.id.menu_app_disabled).setIcon(R.drawable.checked); else menu.findItem(R.id.menu_app_disabled).setIcon(R.drawable.check); // menu.findItem(R.id.menu_app_nointernet).setChecked(prefs.getBoolean("show_nointernet", true)); // menu.findItem(R.id.menu_app_disabled).setChecked(prefs.getBoolean("show_disabled", true)); String sort = prefs.getString("sort", "name"); if ("data".equals(sort)) { menu_data.setChecked(true); menu_data.setIcon(R.drawable.singlechecked); menu_name.setIcon(R.drawable.singlecheck); } else { menu_name.setChecked(true); menu_name.setIcon(R.drawable.singlechecked); menu_data.setIcon(R.drawable.singlecheck); } return super.onPrepareOptionsMenu(menu); }
From source file:fiskinfoo.no.sintef.fiskinfoo.MapFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { // super.onCreateOptionsMenu(menu, inflater); for (int i = 0; i < menu.size(); i++) { menu.removeItem(i); }/* www.j a va 2 s .c o m*/ inflater.inflate(R.menu.menu_map, menu); }
From source file:com.cyanogenmod.eleven.ui.fragments.AudioPlayerFragment.java
public void showPopupMenu() { // create the popup menu if (mPopupMenu == null) { mPopupMenu = new PopupMenu(getActivity(), mMenuButton); mPopupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override//from www.ja v a 2s . c o m public boolean onMenuItemClick(MenuItem item) { return onPopupMenuItemClick(item); } }); } final Menu menu = mPopupMenu.getMenu(); final MenuInflater inflater = mPopupMenu.getMenuInflater(); menu.clear(); // Shuffle all inflater.inflate(R.menu.shuffle_all, menu); if (MusicUtils.getQueueSize() > 0) { // ringtone, and equalizer inflater.inflate(R.menu.audio_player, menu); if (!NavUtils.hasEffectsPanel(getActivity())) { menu.removeItem(R.id.menu_audio_player_equalizer); } // save queue/clear queue inflater.inflate(R.menu.queue, menu); } // Settings inflater.inflate(R.menu.activity_base, menu); // show the popup mPopupMenu.show(); }
From source file:fiskinfoo.no.sintef.fiskinfoo.MyToolsFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { for (int i = 0; i < menu.size(); i++) { menu.removeItem(i); }//from w w w . j a v a 2 s.co m inflater.inflate(R.menu.menu_tool_registration, menu); }