List of usage examples for android.view Menu findItem
public MenuItem findItem(int id);
From source file:za.co.neilson.alarm.AlarmActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { boolean result = super.onCreateOptionsMenu(menu); menu.findItem(R.id.menu_item_save).setVisible(false); menu.findItem(R.id.menu_item_delete).setVisible(false); return result; }
From source file:com.zprogrammer.tool.ui.SearchActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_search, menu); MenuItem searchItem = menu.findItem(R.id.action_search);//??item final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); int id = searchView.getContext().getResources().getIdentifier("search_src_text", "id", BuildConfig.APPLICATION_ID); final EditText editText = (EditText) searchView.findViewById(id); editText.setTextColor(Color.WHITE); MenuItemCompat.setOnActionExpandListener(searchItem, new MenuItemCompat.OnActionExpandListener() { @Override/* ww w . java 2 s.c o m*/ public boolean onMenuItemActionExpand(MenuItem item) { return true; } @Override public boolean onMenuItemActionCollapse(MenuItem item) { ActivityCompat.finishAfterTransition(SearchActivity.this); return true; } }); searchItem.expandActionView(); searchView.setQuery(queryText, false); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { queryText = query; queryDatas(null); return true; } @Override public boolean onQueryTextChange(String newText) { return false; } }); return true; }
From source file:co.nerdart.ourss.fragment.EntriesListFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.entry_list, menu); if (EntryColumns.FAVORITES_CONTENT_URI.equals(mUri)) { menu.findItem(R.id.menu_hide_read).setVisible(false); } else {//from w w w. jav a2 s . c o m menu.findItem(R.id.menu_share_starred).setVisible(false); if (!PrefUtils.getBoolean(PrefUtils.SHOW_READ, true)) { menu.findItem(R.id.menu_hide_read).setTitle(R.string.context_menu_show_read) .setIcon(R.drawable.view_reads); } } super.onCreateOptionsMenu(menu, inflater); }
From source file:ch.berta.fabio.popularmovies.presentation.ui.fragments.MovieDetailsBaseFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.menu_movie_details, menu); MenuItem shareItem = menu.findItem(R.id.menu_details_action_share); shareItem.setVisible(mViewModel.hasMovieVideos()); }
From source file:cf.obsessiveorange.rhcareerfairlayout.ui.fragments.VPCompaniesFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); MenuItem searchBtn = menu.findItem(R.id.action_search); searchBtn.setVisible(true);//ww w .j a v a2 s. com SubMenu selectionMenu = menu.addSubMenu(getResources().getString(R.string.selection_options_btn)); selectionMenu.getItem().setIcon(new IconDrawable(this.getActivity(), Iconify.IconValue.fa_edit) .colorRes(R.color.accentNoTransparency).actionBarSize()); selectionMenu.getItem().setTitle(getResources().getString(R.string.selection_options_btn)); selectionMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); MenuItem selectAllItem = selectionMenu.add(getResources().getString(R.string.btn_select_all)); selectAllItem.setIcon(new IconDrawable(this.getActivity(), Iconify.IconValue.fa_check_square_o) .colorRes(R.color.accentNoTransparency).actionBarSize()); selectAllItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); selectAllItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { Toast.makeText(getActivity(), "Selected all items", Toast.LENGTH_SHORT).show(); try { DBManager.setFilteredCompaniesSelected(true); } catch (SQLException e) { e.printStackTrace(); } ((CompaniesCellAdapter) recyclerView.getAdapter()).refreshData(); synchronized (RHCareerFairLayout.refreshMapNotifier) { RHCareerFairLayout.refreshMapNotifier.notifyChanged(); } return true; } }); MenuItem deselectAllItem = selectionMenu.add(getResources().getString(R.string.btn_deselect_all)); deselectAllItem.setIcon(new IconDrawable(this.getActivity(), Iconify.IconValue.fa_square_o) .colorRes(R.color.accentNoTransparency).actionBarSize()); deselectAllItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); deselectAllItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { Toast.makeText(getActivity(), "Deselected all items", Toast.LENGTH_SHORT).show(); try { DBManager.setFilteredCompaniesSelected(false); } catch (SQLException e) { e.printStackTrace(); } ((CompaniesCellAdapter) recyclerView.getAdapter()).refreshData(); synchronized (RHCareerFairLayout.refreshMapNotifier) { RHCareerFairLayout.refreshMapNotifier.notifyChanged(); } return true; } }); }
From source file:com.bellman.bible.android.control.page.CurrentPageBase.java
@Override public void updateOptionsMenu(Menu menu) { // these are fine for Bible and commentary MenuItem menuItem = menu.findItem(R.id.searchButton); if (menuItem != null) { menuItem.setEnabled(isSearchable()); }/*w ww . j a va 2 s.c o m*/ menuItem = menu.findItem(R.id.bookmarksButton); if (menuItem != null) { menuItem.setEnabled(true); } menuItem = menu.findItem(R.id.speakButton); if (menuItem != null) { menuItem.setEnabled(isSpeakable()); } }
From source file:co.dilaver.quoter.activities.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_main, menu); qodFavorite = menu.findItem(R.id.qod_action_favorite); qodShare = menu.findItem(R.id.qod_action_share); qodCopy = menu.findItem(R.id.qod_action_copy); wyoDone = menu.findItem(R.id.wyo_action_done); wyoShare = menu.findItem(R.id.wyo_action_share); pqInfo = menu.findItem(R.id.pq_action_info); return true;/*from w w w.j a va 2s.c om*/ }
From source file:com.xengar.android.booksearch.ui.BookListActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_book_list, menu); final MenuItem searchItem = menu.findItem(R.id.action_search); final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override/*from ww w . j av a 2s . c o m*/ public boolean onQueryTextSubmit(String query) { // Fetch the data remotely fetchBooks(query); // Reset SearchView searchView.clearFocus(); searchView.setQuery("", false); searchView.setIconified(true); searchItem.collapseActionView(); // Set activity title to search query BookListActivity.this.setTitle(query); return true; } @Override public boolean onQueryTextChange(String s) { return false; } }); return true; }
From source file:ca.rmen.android.palidamuerte.app.poem.detail.PoemDetailFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { Log.v(TAG, "onCreateOptionsMenu"); super.onCreateOptionsMenu(menu, inflater); ActionBar.updateMusicMenuItem(getActivity(), menu.findItem(R.id.action_music)); }
From source file:com.alboteanu.android.sunshine.app.DetailFragment.java
private void finishCreatingMenu(Menu menu) { // Retrieve the share menu item MenuItem menuItem = menu.findItem(R.id.action_share); menuItem.setIntent(createShareForecastIntent()); }