List of usage examples for android.view Menu findItem
public MenuItem findItem(int id);
From source file:net.fred.feedex.activity.EditFeedActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { if (mTabHost.getCurrentTab() == 0) { menu.findItem(R.id.menu_add_filter).setVisible(false); } else {/*from ww w .j av a 2 s. com*/ menu.findItem(R.id.menu_add_filter).setVisible(true); } if (getIntent() != null && getIntent().getAction().equals(Intent.ACTION_EDIT)) { menu.findItem(R.id.menu_validate).setVisible(false); // only in insert mode } return super.onPrepareOptionsMenu(menu); }
From source file:com.zigvine.zagriculture.UIActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); menu.findItem(R.id.menu_logoff).setVisible(MainApp.isSignIn()); //menu.findItem(R.id.menu_aboutus).setEnabled(MainApp.isSignIn()); //menu.findItem(R.id.menu_guide).setVisible(this instanceof MainActivity); //menu.findItem(R.id.menu_settings).setEnabled(false); return true;//from www . j av a 2 s . c o m }
From source file:pl.bcichecki.rms.client.android.fragments.OutboxMessagesListFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); getActivity().getMenuInflater().inflate(R.menu.fragment_outbox_messages_list, menu); MenuItem showArchivedMenuItem = menu.findItem(R.id.fragment_outbox_messages_list_menu_show_archived); showArchivedMenuItem.setChecked(showArchivedMessages); showArchivedMenuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override//ww w . j a va2 s .c o m public boolean onMenuItemClick(MenuItem item) { item.setChecked(!item.isChecked()); showArchivedMessages = item.isChecked(); downloadData(); downloadArchivedData(); return false; } }); }
From source file:de.Maxr1998.xposed.maxlock.ui.settings.appslist.AppListFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.applist_menu, menu); SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.toolbar_search)); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override/*from w w w. j ava 2 s . c o m*/ public boolean onQueryTextSubmit(String s) { return false; } @Override public boolean onQueryTextChange(String s) { mAdapter.getFilter().filter(s); return true; } }); filterIcon(menu.findItem(R.id.toolbar_filter_activated)); }
From source file:pl.bcichecki.rms.client.android.fragments.InboxMessagesListFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); getActivity().getMenuInflater().inflate(R.menu.fragment_inbox_messages_list, menu); MenuItem showArchivedMenuItem = menu.findItem(R.id.fragment_inbox_messages_list_menu_show_archived); showArchivedMenuItem.setChecked(showArchivedMessages); showArchivedMenuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override//from w ww . j av a2 s .c o m public boolean onMenuItemClick(MenuItem item) { item.setChecked(!item.isChecked()); showArchivedMessages = item.isChecked(); downloadData(); downloadArchivedData(); return false; } }); }
From source file:am.hour.beebird.Activity.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { // If the nav drawer is open, hide action items related to the content view // boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerLeftLayout); // menu.findItem(R.id.action_websearch).setVisible(!drawerOpen); menu.findItem(R.id.action_websearch).setVisible(false); return super.onPrepareOptionsMenu(menu); }
From source file:ch.kanti_baden.pu_marc_14b.traffictimewaste.SORT_TYPE.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu_post_list, menu); // Disable create post button if user isn't logged in if (DatabaseLink.instance.isLoggedIn()) { MenuItem menuItem = menu.findItem(R.id.action_login); menuItem.setEnabled(false);//from w w w . j av a 2 s . c o m } else { MenuItem menuItem = menu.findItem(R.id.action_create); menuItem.setEnabled(false); Drawable icon = menuItem.getIcon(); icon.mutate().setColorFilter(Color.GRAY, PorterDuff.Mode.SRC_IN); menuItem.setIcon(icon); } // Get the SearchView and set the searchable configuration SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); final SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView(); searchView.setOnSearchClickListener(new View.OnClickListener() { @Override public void onClick(View v) { searchView.setTranslationX(500f); searchView.setAlpha(0f); searchView.animate().translationX(0); searchView.animate().alpha(1f); } }); // Assumes current activity is the searchable activity searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); return true; }
From source file:com.agateau.equiv.ui.MealItemDetailActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.meal_item_detail_activity_actions, menu); if (mMealItemPosition == NEW_MEAL_ITEM_POSITION) { MenuItem removeMenuItem = menu.findItem(R.id.action_remove); removeMenuItem.setVisible(false); }//from w w w. ja v a 2s. c o m mSaveMenuItem = menu.findItem(R.id.action_save); SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView(); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { return false; } @Override public boolean onQueryTextChange(String newText) { mFullListAdapter.getFilter().filter(newText); mFavoritesListAdapter.getFilter().filter(newText); return false; } }); updateMenuItems(); return super.onCreateOptionsMenu(menu); }
From source file:com.hybris.mobile.activity.StoreLocatorActivity.java
/** * Menu methods// w ww. ja v a 2 s . c o m */ @Override public boolean onCreateOptionsMenu(final Menu menu) { MenuInflater inflater = this.getMenuInflater(); inflater.inflate(R.menu.store_finder, menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); MenuItem searchViewMenuItem = menu.findItem(R.id.store_search); this.mSearchView = searchViewMenuItem; SearchView searchView = ((SearchView) searchViewMenuItem.getActionView()); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(true); searchView.setQueryHint(getResources().getString(R.string.store_search_hint)); searchView.setOnQueryTextListener(this); return true; }
From source file:de.baumann.hhsmoodle.data_random.Random_Fragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. super.onPrepareOptionsMenu(menu); menu.findItem(R.id.action_filter).setVisible(false); menu.findItem(R.id.action_sort).setVisible(false); getActivity().setTitle(R.string.number_title); setRandomList();/*from w ww .j ava2s.c om*/ }