List of usage examples for android.view MenuItem setChecked
public MenuItem setChecked(boolean checked);
From source file:org.csploit.android.plugins.Traceroute.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.resolve_names: resolveNames = !item.isChecked(); item.setChecked(resolveNames); return true; default:/*w ww .j av a 2s . c o m*/ return super.onOptionsItemSelected(item); } }
From source file:org.digitalcampus.oppia.utils.ui.DrawerMenuManager.java
public void onPrepareOptionsMenu(Menu menu, Integer currentOption, Map<Integer, MenuOption> options) { if (options != null) this.customOptions = options; Menu drawerMenu = navigationView.getMenu(); MenuItem itemLogout = drawerMenu.findItem(R.id.menu_logout); MenuItem itemSettings = drawerMenu.findItem(R.id.menu_settings); MenuItem itemMonitor = drawerMenu.findItem(R.id.menu_monitor); MenuItem itemCourseDownload = drawerMenu.findItem(R.id.menu_download); MenuItem itemLanguageDialog = drawerMenu.findItem(R.id.menu_language); if (currentOption != null) { MenuItem current = drawerMenu.findItem(currentOption); if (current != null) { current.setCheckable(true);//from w w w.ja v a 2 s .c o m current.setChecked(true); } } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(drawerAct); itemLogout .setVisible(prefs.getBoolean(PrefsActivity.PREF_LOGOUT_ENABLED, MobileLearning.MENU_ALLOW_LOGOUT)); itemSettings.setVisible(MobileLearning.MENU_ALLOW_SETTINGS); itemMonitor.setVisible(MobileLearning.MENU_ALLOW_MONITOR); itemCourseDownload.setVisible(MobileLearning.MENU_ALLOW_COURSE_DOWNLOAD); itemLanguageDialog.setVisible(customOptions.containsKey(R.id.menu_language)); }
From source file:com.jaysen.mddp.AppBarLayoutActivity.java
@Override public boolean onNavigationItemSelected(MenuItem menuItem) { int id = menuItem.getItemId(); switch (id) { case R.id.navItem1: break;/*from www. j ava 2s .c o m*/ case R.id.navItem2: break; case R.id.navItem3: break; } menuItem.setChecked(true); mDrawerLayout.closeDrawer(mNavigation); return true; }
From source file:com.stoyanr.feeder.activity.ItemsActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); getMenuInflater().inflate(R.menu.items_menu, menu); MenuUtils.setShowAsActionAll(menu);/*from w ww . ja v a 2s .c o m*/ MenuItem item = menu.findItem(R.id.view_featured); item.setChecked(featuredOnly); int iconRes = featuredOnly ? R.drawable.btn_check_on : R.drawable.btn_check_off; item.setIcon(iconRes); if (prevChannelId < 0) { menu.removeItem(R.id.prev_channel); } if (nextChannelId < 0) { menu.removeItem(R.id.next_channel); } return true; }
From source file:org.csploit.android.plugins.Inspector.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { MenuItem item = menu.findItem(R.id.focused_scan); if (item != null) { item.setChecked(mFocusedScan); item.setEnabled(System.getCurrentTarget().hasOpenPorts()); }// www. j a v a 2 s. com return super.onPrepareOptionsMenu(menu); }
From source file:de.aw.monma.mainscreen.FragmentFinanzen.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_item_showHiddenAccounts: zeigeAusgeblendeteKonten = !zeigeAusgeblendeteKonten; item.setChecked(zeigeAusgeblendeteKonten); SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean(getString(R.string.menu_item_hideAccounts), zeigeAusgeblendeteKonten).apply(); return true; default:/*from www . j av a2s . co m*/ return super.onOptionsItemSelected(item); } }
From source file:com.jkenneth.droidovpn.ui.activity.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); switch (id) { case R.id.sort_country: item.setChecked(item.isChecked()); sort(SORT_COUNTRY);/*from ww w .j a va 2 s . c om*/ break; case R.id.sort_speed: item.setChecked(item.isChecked()); sort(SORT_SPEED); break; case R.id.sort_ping: item.setChecked(item.isChecked()); sort(SORT_PING); break; case R.id.action_licenses: LicensesDialogFragment licensesDialog = new LicensesDialogFragment(); licensesDialog.show(getSupportFragmentManager(), "licenses_dialog"); break; case R.id.action_settings: break; } return super.onOptionsItemSelected(item); }
From source file:com.popumovies.MainActivityFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.menu_main, menu); int item = PrefUtil.getInt(getActivity(), getString(R.string.pref_filter_label), R.id.action_sort_popularity); MenuItem menuItem = menu.findItem(item); if (menuItem == null) menuItem = menu.findItem(R.id.action_sort_popularity); menuItem.setChecked(true); mMenu = menu;//from w w w. java2 s .c o m }
From source file:com.ccjeng.weather.view.activity.MainActivity.java
private void navDrawer() { navigation.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override//from w ww .j a v a2 s. c om public boolean onNavigationItemSelected(MenuItem menuItem) { //Checking if the item is in checked state or not, if not make it in checked state if (menuItem.isChecked()) menuItem.setChecked(false); else menuItem.setChecked(true); //Closing drawer on item click drawerLayout.closeDrawers(); switch (menuItem.getItemId()) { case R.id.navSetting: startActivity(new Intent(MainActivity.this, SettingsActivity.class)); break; case R.id.navAbout: new LibsBuilder().withActivityStyle(Libs.ActivityStyle.LIGHT_DARK_TOOLBAR) .withAboutIconShown(true).withAboutVersionShown(true) .withAboutAppName(getString(R.string.app_name)) .withActivityTitle(getString(R.string.action_about)) .withAboutDescription(getString(R.string.about_license)).start(MainActivity.this); break; } return false; } }); actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.app_name, R.string.app_name) { @Override public void onDrawerClosed(View drawerView) { super.onDrawerClosed(drawerView); } @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } }; //Setting the actionbarToggle to drawer layout drawerLayout.setDrawerListener(actionBarDrawerToggle); //calling sync state is necessay or else your hamburger icon wont show up actionBarDrawerToggle.syncState(); }
From source file:com.example.hp.smartstor.CloudMusicManager.uamp.ui.ActionBarCastActivity.java
private void populateDrawerItems(NavigationView navigationView) { navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override/*from www . j a v a 2s. c o m*/ public boolean onNavigationItemSelected(MenuItem menuItem) { menuItem.setChecked(true); mItemToOpenWhenDrawerCloses = menuItem.getItemId(); mDrawerLayout.closeDrawers(); return true; } }); if (com.example.hp.smartstor.CloudMusicManager.uamp.ui.MusicPlayerActivity.class .isAssignableFrom(getClass())) { navigationView.setCheckedItem(R.id.navigation_allmusic); } else if (com.example.hp.smartstor.CloudMusicManager.uamp.ui.PlaceholderActivity.class .isAssignableFrom(getClass())) { navigationView.setCheckedItem(R.id.navigation_playlists); } }