List of usage examples for android.view Menu add
public MenuItem add(@StringRes int titleRes);
From source file:com.wellsandwhistles.android.redditsp.fragments.CommentListingFragment.java
@Override public void onCreateOptionsMenu(Menu menu) { if (mAllUrls != null && mAllUrls.size() > 0 && mAllUrls.get(0).pathType() == RedditURLParser.POST_COMMENT_LISTING_URL) { menu.add(R.string.action_reply); }/*from w ww .jav a 2 s .c o m*/ }
From source file:com.examples.abelanav2.ui.PicturesFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { MenuItem refreshMenu = menu.add(R.string.action_refresh); refreshMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT); refreshMenu.setOnMenuItemClickListener(this); super.onCreateOptionsMenu(menu, inflater); }
From source file:com.squareup.leakcanary.internal.DisplayLeakActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { AnalyzedHeap visibleLeak = getVisibleLeak(); if (visibleLeak != null) { menu.add(R.string.leak_canary_share_leak) .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override/*from ww w.ja va 2 s .c o m*/ public boolean onMenuItemClick(MenuItem item) { shareLeak(); return true; } }); if (visibleLeak.heapDumpFileExists) { menu.add(R.string.leak_canary_share_heap_dump) .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { shareHeapDump(); return true; } }); } return true; } return false; }
From source file:com.melchor629.musicote.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { //Create the search view SearchView searchView = new SearchView(getActionBar().getThemedContext()); searchView.setQueryHint(getResources().getString(R.string.menu_search)); searchView.setOnQueryTextListener(this); menu.add("Search") .setIcon(new IconDrawable(this, Iconify.IconValue.fa_search).color(Color.WHITE).actionBarSize())//android.R.drawable.ic_menu_search) .setActionView(searchView)//from w w w.j a v a2 s.c o m .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); getMenuInflater().inflate(R.menu.main, menu); menu.findItem(R.id.ajustesm) .setIcon(new IconDrawable(this, Iconify.IconValue.fa_cogs).color(Color.WHITE).actionBarSize()); menu.findItem(R.id.parar) .setIcon(new IconDrawable(this, Iconify.IconValue.fa_music).color(Color.WHITE).actionBarSize()); return true; }
From source file:de.spiritcroc.ownlog.ui.view.EditTagsView.java
private void showAddTagMenu() { // Ensure we have a tags provider if (mTagsProvider == null) { Log.e(TAG, "Cannot load tags: no tags provider"); return;//from w w w .jav a 2s . c o m } // Use context from activity instead of getContext() to separate popup from // this view's theme (padding etc.) PopupMenu popupMenu = new PopupMenu(mTagsProvider.getActivity(), mAddTagButton); Menu menu = popupMenu.getMenu(); final List<TagItem> availableTags = mTagsProvider.getAvailableTags(); final List<TagItem> setTags = mTagsProvider.getSetTags(); final HashMap<String, TagItem> tagMap = new HashMap<>(); for (TagItem tag : availableTags) { if (mAvailableTagsFilter.shouldShowTag(tag)) { menu.add(tag.name); tagMap.put(tag.name, tag); } } menu.add(R.string.edit_log_tags_add_new); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { String name = menuItem.getTitle().toString(); if (tagMap.containsKey(name)) { setTags.add(tagMap.get(name)); mTagsProvider.onSetTagsChanged(); updateContent(); } else { new TagItemEditFragment().show(mTagsProvider.getActivity().getFragmentManager(), "TagItemEditFragment"); } return false; } }); popupMenu.show(); }
From source file:com.hughes.android.dictionary.DictionaryApplication.java
public void onCreateGlobalOptionsMenu(final Context context, final Menu menu) { final MenuItem about = menu.add(getString(R.string.about)); MenuItemCompat.setShowAsAction(about, MenuItem.SHOW_AS_ACTION_NEVER); about.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(final MenuItem menuItem) { final Intent intent = new Intent(getApplicationContext(), AboutActivity.class); context.startActivity(intent); return false; }/*from w ww .ja va 2 s . c o m*/ }); final MenuItem help = menu.add(getString(R.string.help)); MenuItemCompat.setShowAsAction(help, MenuItem.SHOW_AS_ACTION_NEVER); help.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(final MenuItem menuItem) { context.startActivity(HtmlDisplayActivity.getHelpLaunchIntent(getApplicationContext())); return false; } }); final MenuItem preferences = menu.add(getString(R.string.settings)); MenuItemCompat.setShowAsAction(preferences, MenuItem.SHOW_AS_ACTION_NEVER); preferences.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(final MenuItem menuItem) { PreferenceActivity.prefsMightHaveChanged = true; final Intent intent = new Intent(getApplicationContext(), PreferenceActivity.class); context.startActivity(intent); return false; } }); final MenuItem reportIssue = menu.add(getString(R.string.reportIssue)); MenuItemCompat.setShowAsAction(reportIssue, MenuItem.SHOW_AS_ACTION_NEVER); reportIssue.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(final MenuItem menuItem) { final Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("http://github.com/rdoeffinger/Dictionary/issues")); context.startActivity(intent); return false; } }); }
From source file:gov.wa.wsdot.android.wsdot.ui.traveltimes.TravelTimesFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); //Create the search view SearchView searchView = new SearchView( ((BaseActivity) getActivity()).getSupportActionBar().getThemedContext()); searchView.setQueryHint("Search Travel Times"); searchView.setOnQueryTextListener(this); MenuItem menuItem_Search = menu.add(R.string.search_title).setIcon(R.drawable.ic_menu_search); MenuItemCompat.setActionView(menuItem_Search, searchView); MenuItemCompat.setShowAsAction(menuItem_Search, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); MenuItemCompat.setOnActionExpandListener(menuItem_Search, new MenuItemCompat.OnActionExpandListener() { public boolean onMenuItemActionCollapse(MenuItem item) { viewModel.setQueryTerm(""); return true; }//from w w w . j a va 2 s .c o m public boolean onMenuItemActionExpand(MenuItem item) { return true; } }); }
From source file:com.berniesanders.fieldthebern.MainActivity.java
private void handleOptionsMenu(Menu menu) { if (actionBarMenuAction != null) { if (actionBarMenuAction.isSearch()) { setupSearchMenu(menu);//ww w. j a va 2 s . c o m } else { menu.add(actionBarMenuAction.label()).setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS) .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { actionBarMenuAction.action().call(); return true; } }); } // // Inflate the options menu from XML // MenuInflater inflater = getMenuInflater(); // inflater.inflate(R.menu.menu_cancel, menu); } }
From source file:com.hughes.android.dictionary.DictionaryManagerActivity.java
@Override public boolean onCreateOptionsMenu(final Menu menu) { final MenuItem sort = menu.add(getString(R.string.sortDicts)); MenuItemCompat.setShowAsAction(sort, MenuItem.SHOW_AS_ACTION_NEVER); sort.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { public boolean onMenuItemClick(final MenuItem menuItem) { application.sortDictionaries(); setMyListAdapater();//from w w w .j av a 2 s . c o m return true; } }); application.onCreateGlobalOptionsMenu(this, menu); return true; }
From source file:no.olav.samples.facedetect.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { Log.i(TAG, "called onCreateOptionsMenu"); viewDb = menu.add("View DB"); transfearDb = menu.add("Tranfear DB"); return true;/* ww w.j a v a 2s . com*/ }