List of usage examples for android.view MenuItem setChecked
public MenuItem setChecked(boolean checked);
From source file:nu.firetech.android.pactrack.frontend.ParcelDetailsFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); boolean enabled = (Preferences.getPreferences(getActivity()).getCheckInterval() > 0); MenuItem autoInclude = menu.findItem(R.id.action_auto_include); autoInclude.setEnabled(enabled);// w ww. j a va 2 s . c om autoInclude.setChecked(enabled && mDbAdapter.getAutoUpdate(mRowId)); }
From source file:no.hiof.anl.laundrybooking.MainActivity.java
private void setupDrawerLayout() { drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); NavigationView view = (NavigationView) findViewById(R.id.navigation_view); view.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override/*from ww w .java 2 s .co m*/ public boolean onNavigationItemSelected(MenuItem menuItem) { menuItem.setChecked(false); switch (menuItem.getItemId()) { case R.id.drawer_home: menuItem.setChecked(false); drawerLayout.closeDrawers(); return true; case R.id.drawer_statistics: Intent i = new Intent(getApplicationContext(), StatisticsActivity.class); startActivity(i); return true; case R.id.drawer_booking: i = new Intent(getApplicationContext(), BookingActivity.class); startActivity(i); drawerLayout.closeDrawers(); return true; case R.id.drawer_observation: i = new Intent(getApplicationContext(), ObservationActivity.class); startActivity(i); drawerLayout.closeDrawers(); return true; case R.id.drawer_setting: i = new Intent(getApplicationContext(), NotificationActivity.class); startActivity(i); drawerLayout.closeDrawers(); return true; case R.id.drawer_about: Snackbar.make(content, menuItem.getTitle() + " pressed", Snackbar.LENGTH_LONG).show(); menuItem.setChecked(false); drawerLayout.closeDrawers(); return true; case R.id.drawer_my_booking: i = new Intent(getApplicationContext(), MyBookingActivity.class); startActivity(i); drawerLayout.closeDrawers(); return true; default: Snackbar.make(content, menuItem.getTitle() + " pressed", Snackbar.LENGTH_LONG).show(); menuItem.setChecked(false); drawerLayout.closeDrawers(); return true; } } }); drawerName = (TextView) drawerLayout.findViewById(R.id.drawer_name); //drawerEmail = (TextView) drawerLayout.findViewById(R.id.drawer_email); }
From source file:com.meetingninja.csse.agenda.AgendaActivity.java
@Override public boolean onPrepareOptionsMenu(final Menu menu) { final MenuItem collapsibleMenu = menu.findItem(R.id.collapsible_menu_item); if (collapsible) { collapsibleMenu.setTitle(R.string.collapsible_menu_disable); collapsibleMenu.setTitleCondensed(getResources().getString(R.string.collapsible_condensed_disable)); collapsibleMenu.setChecked(collapsible); } else {/*from ww w .j av a 2 s . c om*/ collapsibleMenu.setTitle(R.string.collapsible_menu_enable); collapsibleMenu.setTitleCondensed(getResources().getString(R.string.collapsible_condensed_enable)); } return super.onPrepareOptionsMenu(menu); }
From source file:com.google.android.apps.forscience.whistlepunk.project.ProjectTabsFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); MenuItem includeArchived = menu.findItem(R.id.action_include_archived); includeArchived.setChecked(mIncludeArchived); }
From source file:com.sudhirkhanger.app.popularmoviesstageone.TitlesFragment.java
/** * User makes choice about sorting/*from w w w . j a va 2 s . co m*/ * There are two possibilities * First on basis of popularity * Second on basis of average rating * * @param item * @return */ @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.popularity: mEditor.putString(SHARED_KEY_SORT, POPULARITY); mEditor.apply(); updateScreen(); item.setChecked(true); return true; case R.id.rating: mEditor.putString(SHARED_KEY_SORT, RATING); mEditor.apply(); updateScreen(); item.setChecked(true); return true; } return super.onOptionsItemSelected(item); }
From source file:ca.ualberta.cmput301w14t08.geochan.fragments.ThreadListFragment.java
/** * Sets the user selected sorting option in our options menu. * @param sort Code for the type of sort being used. * @param menu The fragment's menu.// www . j a v a2 s . c o m */ private void setSortCheck(int sort, Menu menu) { MenuItem item; switch (sort) { case SortUtil.SORT_DATE_NEWEST: item = menu.findItem(R.id.thread_sort_date_new); item.setChecked(true); return; case SortUtil.SORT_DATE_OLDEST: item = menu.findItem(R.id.thread_sort_date_new); item.setChecked(true); return; case SortUtil.SORT_LOCATION: item = menu.findItem(R.id.thread_sort_location); item.setChecked(true); return; case SortUtil.SORT_USER_SCORE_HIGHEST: item = menu.findItem(R.id.thread_sort_score_high); item.setChecked(true); return; case SortUtil.SORT_USER_SCORE_LOWEST: item = menu.findItem(R.id.thread_sort_score_low); item.setChecked(true); return; default: return; } }
From source file:com.heske.alexandria.activities.MainActivity.java
protected void selectDrawerItem(MenuItem menuItem) { menuItem.setChecked(true); switch (menuItem.getItemId()) { case R.id.nav_list_books: if (mIsTwoPane) { //If it's already showing then don't load it again //mIsInitState = a special condition where //Activity has just been created so everything has to be displayed if ((mCurrentNavPosition == NAV_ITEM_LIST) && (!mIsInitState)) displayFragment(BookDetailFragment.class, R.id.frame_detail_container); else/*from www . ja v a 2s . co m*/ displayMasterDetailFragments(BookDetailFragment.class); } else displayFragment(ListOfBooksFragment.class, R.id.frame_fullscreen_container); mCurrentNavPosition = NAV_ITEM_LIST; mIsInitState = false; //true = display first book in BookDetailFragment //false = user did not make selection mListOfBooksFragment.restartLoader(true, false); break; case R.id.nav_add_books: invalidateOptionsMenu(); if (mIsTwoPane) { mCurrentNavPosition = NAV_ITEM_ADD_BOOKS; if (!mIsInitState) displayFragment(AddBookFragment.class, R.id.frame_detail_container); else displayMasterDetailFragments(AddBookFragment.class); } else //Once book is added, AddBookActivity closes //and onActivityResult displays the updated list startActivityForResult(new Intent(this, AddBookActivity.class), REQUEST_ADD_BOOK); break; case R.id.nav_about: mCurrentNavPosition = NAV_ITEM_ABOUT; startActivity(new Intent(this, AboutActivity.class)); break; case R.id.nav_settings: mCurrentNavPosition = NAV_ITEM_SETTINGS; startActivity(new Intent(this, SettingsActivity.class)); break; default: mCurrentNavPosition = NAV_ITEM_LIST; } mDrawer.closeDrawers(); }
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/*from w w w .j av a2s . c o m*/ public boolean onMenuItemClick(MenuItem item) { item.setChecked(!item.isChecked()); showArchivedMessages = item.isChecked(); downloadData(); downloadArchivedData(); return false; } }); }
From source file:info.wncwaterfalls.app.InformationMapFragment.java
private boolean setMapTypeIfUnchecked(MenuItem item, int newType) { GoogleMap googleMap = mMapView.getMap(); if (!item.isChecked()) { googleMap.setMapType(newType);//w ww . java 2 s. co m item.setChecked(true); } return true; }
From source file:org.gdg.frisbee.android.common.GdgNavDrawerActivity.java
private void setupDrawerContent(NavigationView navigationView) { Menu menu = navigationView.getMenu(); menu.add(GROUP_ID, Const.DRAWER_HOME, Menu.NONE, R.string.home_gdg).setIcon(R.drawable.ic_drawer_home_gdg); menu.add(GROUP_ID, Const.DRAWER_GDE, Menu.NONE, R.string.gde).setIcon(R.drawable.ic_drawer_gde); menu.add(GROUP_ID, Const.DRAWER_PULSE, Menu.NONE, R.string.pulse).setIcon(R.drawable.ic_drawer_pulse); //adding special events in navigation drawer final ArrayList<TaggedEventSeries> currentEventSeries = App.getInstance().currentTaggedEventSeries(); for (TaggedEventSeries taggedEventSeries : currentEventSeries) { menu.add(GROUP_ID, taggedEventSeries.getDrawerId(), Menu.NONE, taggedEventSeries.getTitleResId()) .setIcon(taggedEventSeries.getDrawerIconResId()); }// ww w .j ava 2s . co m SubMenu subMenu = menu.addSubMenu(GAMES_GROUP_ID, Const.DRAWER_SUBMENU_GAMES, Menu.NONE, R.string.drawer_subheader_games); subMenu.add(GAMES_GROUP_ID, Const.DRAWER_ACHIEVEMENTS, Menu.NONE, R.string.achievements) .setIcon(R.drawable.ic_drawer_achievements); subMenu.add(GAMES_GROUP_ID, Const.DRAWER_ARROW, Menu.NONE, R.string.arrow) .setIcon(R.drawable.ic_drawer_arrow).setCheckable(true); menu.add(SETTINGS_GROUP_ID, Const.DRAWER_SETTINGS, Menu.NONE, R.string.settings) .setIcon(R.drawable.ic_drawer_settings); menu.add(SETTINGS_GROUP_ID, Const.DRAWER_HELP, Menu.NONE, R.string.help).setIcon(R.drawable.ic_drawer_help); menu.add(SETTINGS_GROUP_ID, Const.DRAWER_FEEDBACK, Menu.NONE, R.string.feedback) .setIcon(R.drawable.ic_drawer_feedback); menu.add(SETTINGS_GROUP_ID, Const.DRAWER_ABOUT, Menu.NONE, R.string.about) .setIcon(R.drawable.ic_drawer_about); menu.setGroupCheckable(GROUP_ID, true, true); final int selectedDrawerItemId = getIntent().getIntExtra(EXTRA_SELECTED_DRAWER_ITEM_ID, Const.DRAWER_HOME); final MenuItem selectedItem = menu.findItem(selectedDrawerItemId); if (selectedItem != null) { selectedItem.setChecked(true); } navigationView.setNavigationItemSelectedListener( new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { onDrawerItemClick(menuItem); mDrawerLayout.closeDrawers(); return true; } }); View headerView = navigationView.getHeaderView(0); mDrawerImage = ButterKnife.findById(headerView, R.id.navdrawer_image); mDrawerUserPicture = ButterKnife.findById(headerView, R.id.navdrawer_user_picture); }