List of usage examples for android.view Menu findItem
public MenuItem findItem(int id);
From source file:com.android.calculator2.StoreActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); MenuItem info = menu.findItem(R.id.info); info.setIcon(// w w w. j av a 2s . c om Theme.isLightTheme(getContext()) ? R.drawable.action_about_grey : R.drawable.action_about_white); return true; }
From source file:android.example.com.animationdemos.ScreenSlideActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.activity_screen_slide, menu); menu.findItem(R.id.action_previous).setEnabled(mPager.getCurrentItem() > 0); // Add either a "next" or "finish" button to the action bar, depending on which page // is currently selected. MenuItem item = menu.add(Menu.NONE, R.id.action_next, Menu.NONE, (mPager.getCurrentItem() == mPagerAdapter.getCount() - 1) ? R.string.action_finish : R.string.action_next); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT); return true;//from www. jav a 2 s .com }
From source file:net.reichholf.dreamdroid.activities.VirtualRemoteActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { menu.findItem(MENU_LAYOUT).setTitle(mQuickZap ? R.string.standard : R.string.quickzap); return true;//from www . j a va 2 s. c om }
From source file:co.iyubinest.bonzai.photos.list.PhotoListActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.photo_list_search_menu, menu); MenuItem searchMenuItem = menu.findItem(R.id.action_search); searchView = (SearchView) searchMenuItem.getActionView(); searchView.setOnQueryTextListener(listener); searchView.setOnQueryTextFocusChangeListener((v, hasFocus) -> { if (!hasFocus) { MenuItemCompat.collapseActionView(searchMenuItem); }//from w w w .j ava 2s. com }); MenuItemCompat.setOnActionExpandListener(searchMenuItem, new MenuItemCompat.OnActionExpandListener() { @Override public boolean onMenuItemActionExpand(MenuItem item) { photosView.setVisibility(View.INVISIBLE); return true; } @Override public boolean onMenuItemActionCollapse(MenuItem item) { photosView.setVisibility(View.VISIBLE); return true; } }); return true; }
From source file:com.github.akinaru.hcidebugger.activity.DescriptionActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { this.getMenuInflater().inflate(R.menu.toolbar_menu, menu); menu.findItem(R.id.packet_number_entry).setVisible(false); menu.findItem(R.id.clear_btn).setVisible(false); menu.findItem(R.id.scan_btn).setVisible(false); menu.findItem(R.id.state_bt_btn).setVisible(false); menu.findItem(R.id.reset_snoop_file).setVisible(false); menu.findItem(R.id.filter_btn).setVisible(false); menu.findItem(R.id.refresh).setVisible(false); MenuItem item = menu.findItem(R.id.share); if (item != null) { mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item); setSharedIntent();// ww w .j a va 2 s . co m } return super.onCreateOptionsMenu(menu); }
From source file:com.duguang.baseanimation.ui.listivew.listviews.ListViewsMainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_main, menu); menu.findItem(R.id.menu_main_donate).setVisible(mService != null); return super.onCreateOptionsMenu(menu); }
From source file:cf.obsessiveorange.rhcareerfairlayout.ui.fragments.VPFiltersFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); MenuItem searchBtn = menu.findItem(R.id.action_search); searchBtn.setVisible(false);/*from w w w . ja v a 2 s . c o m*/ ((MainActivity) getActivity()).closeSearch(); MenuItem clearFiltersItem = menu.add(getResources().getString(R.string.btn_clear_filters)); clearFiltersItem.setIcon(new IconDrawable(this.getActivity(), Iconify.IconValue.fa_times) .colorRes(R.color.accentNoTransparency).actionBarSize()); clearFiltersItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); clearFiltersItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { Toast.makeText(getActivity(), "Filters cleared", Toast.LENGTH_SHORT).show(); try { DBManager.setAllCategoriesSelected(false); } catch (SQLException e) { e.printStackTrace(); } ((FiltersCellAdapter) recyclerView.getAdapter()).refreshData(); synchronized (RHCareerFairLayout.refreshCompaniesNotifier) { RHCareerFairLayout.refreshCompaniesNotifier.notifyChanged(); } getActivity().runOnUiThread(new Runnable() { @Override public void run() { recyclerView.getAdapter().notifyDataSetChanged(); } }); return true; } }); }
From source file:br.liveo.ndrawer.MainActivity.java
@Override public void onPrepareOptionsMenuNavigation(Menu menu, int position, boolean visible) { //hide the menu when the navigation is opens switch (position) { case 0:// w w w. j a v a 2s. c o m menu.findItem(R.id.menu_add).setVisible(!visible); menu.findItem(R.id.menu_search).setVisible(!visible); break; case 1: menu.findItem(R.id.menu_add).setVisible(!visible); menu.findItem(R.id.menu_search).setVisible(!visible); break; } }
From source file:com.haarman.listviewanimations.MainActivity.java
@Override public boolean onCreateOptionsMenu(final Menu menu) { getMenuInflater().inflate(R.menu.menu_main, menu); menu.findItem(R.id.menu_main_donate).setVisible(mService != null); return super.onCreateOptionsMenu(menu); }
From source file:com.github.michalbednarski.intentslab.browser.ApplicationFetcher.java
@Override void onPrepareOptionsMenu(Menu menu) { if (appType == APP_TYPE_USER) { menu.findItem(R.id.system_apps).setVisible(true); } else if (appType == APP_TYPE_SYSTEM) { menu.findItem(R.id.user_apps).setVisible(true); }// w w w . j a v a 2s .c o m menu.findItem(R.id.applications).setChecked(true); }