List of usage examples for android.view MenuItem setChecked
public MenuItem setChecked(boolean checked);
From source file:com.github.rubensousa.navigationmanager.NavigationManager.java
public void navigate(@IdRes int menuId) { if (mCurrentId != menuId) { MenuItem newItem = mNavigationView.getMenu().findItem(menuId); if (newItem != null) { MenuItem lastItem = mNavigationView.getMenu().findItem(mCurrentId); if (lastItem != null) { lastItem.setChecked(false); }/*from ww w .j a v a2 s .c o m*/ mNavigating = true; onNavigationItemSelected(newItem); } } }
From source file:com.martin.designlibrary.MainActivity.java
private void setupDrawerContent(final NavigationView navigationView) { navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override/*from w w w.j ava 2 s .c om*/ public boolean onNavigationItemSelected(MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.nav_home: mSelected = 0; break; case R.id.nav_messages: mSelected = 1; break; } menuItem.setChecked(true); mDrawerLayout.closeDrawers(); return true; } }); }
From source file:com.sudhirkhanger.app.popularmovies.MainFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.popularity: mEditor.putString(PREF, URL_POPULARITY); mEditor.apply();/*from ww w . j a v a 2 s . co m*/ updateMovieList(); item.setChecked(true); Log.d(LOG_TAG, "onOptionsItemSelected: popularity"); return true; case R.id.rating: mEditor.putString(PREF, URL_RATING); mEditor.apply(); updateMovieList(); item.setChecked(true); Log.d(LOG_TAG, "onOptionsItemSelected: rating"); return true; case R.id.favorite: mEditor.putString(PREF, URL_FAVORITE); mEditor.apply(); updateMovieList(); item.setChecked(true); Log.d(LOG_TAG, "onOptionsItemSelected: favorite"); return true; } return super.onOptionsItemSelected(item); }
From source file:com.miz.mizuu.fragments.CoverSearchFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { getActivity().onBackPressed();/*from w w w . j a v a 2 s . co m*/ return true; } item.setChecked(true); if (item.getItemId() == 0) { mImageUrls.clear(); for (int i = 0; i < mCovers.size(); i++) mImageUrls.add(mCovers.get(i).getUrl()); if (mAdapter != null) ((BaseAdapter) mGridView.getAdapter()).notifyDataSetChanged(); } else { mImageUrls.clear(); for (int i = 0; i < mCovers.size(); i++) if (mCovers.get(i).getLanguage().equals(mItems[item.getItemId()])) mImageUrls.add(mCovers.get(i).getUrl()); if (mAdapter != null) ((BaseAdapter) mGridView.getAdapter()).notifyDataSetChanged(); } return super.onOptionsItemSelected(item); }
From source file:com.android.settings.applications.AppOpsSummary.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.show_user_apps: final String prefNameUserApps = "show_user_apps"; // set the menu checkbox and save it in shared preference item.setChecked(!item.isChecked()); mPreferences.edit().putBoolean(prefNameUserApps, item.isChecked()).commit(); // reload content resetAdapter();/* w ww . j a v a 2 s . c om*/ return true; case R.id.show_system_apps: final String prefNameSysApps = "show_system_apps"; // set the menu checkbox and save it in shared preference item.setChecked(!item.isChecked()); mPreferences.edit().putBoolean(prefNameSysApps, item.isChecked()).commit(); // reload view content resetAdapter(); return true; case R.id.reset_counters: resetCountersConfirm(); return true; default: return super.onContextItemSelected(item); } }
From source file:com.sakisds.icymonitor.fragments.history.HistoryPickerFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.item_sort_newestFirst: mSort = "true"; mPullToRefreshLayout.setRefreshing(true); refreshData();/*from ww w.j a v a 2 s . c o m*/ item.setChecked(true); return true; case R.id.item_sort_oldestFirst: mSort = "false"; mPullToRefreshLayout.setRefreshing(true); refreshData(); item.setChecked(true); return true; } return super.onOptionsItemSelected(item); }
From source file:com.miz.mizuu.fragments.CollectionCoverSearchFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { getActivity().onBackPressed();//from w ww. ja va 2 s . co m return true; } item.setChecked(true); if (item.getItemId() == 0) { mImageUrls.clear(); for (int i = 0; i < mCovers.size(); i++) mImageUrls.add(mCovers.get(i).getUrl()); if (mAdapter != null) ((BaseAdapter) mGridView.getAdapter()).notifyDataSetChanged(); } else { mImageUrls.clear(); for (int i = 0; i < mCovers.size(); i++) { if (mCovers.get(i).getLanguage().equals(mItems[item.getItemId()])) { mImageUrls.add(mCovers.get(i).getUrl()); } } if (mAdapter != null) ((BaseAdapter) mGridView.getAdapter()).notifyDataSetChanged(); } return super.onOptionsItemSelected(item); }
From source file:nu.firetech.android.pactrack.frontend.ParcelListFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); MenuInflater inflater = getActivity().getMenuInflater(); inflater.inflate(R.menu.parcel_menu, menu); AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; boolean enabled = (Preferences.getPreferences(getActivity()).getCheckInterval() > 0); MenuItem autoInclude = menu.findItem(R.id.action_auto_include); autoInclude.setEnabled(enabled);//from w ww.ja va 2 s . c om autoInclude.setChecked(enabled && mDbAdapter.getAutoUpdate(info.id)); }
From source file:com.sakisds.icymonitor.fragments.ProcessesFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.item_sort_by_name: mSort = "name"; mPullToRefreshLayout.setRefreshing(true); refreshData();/*from w ww . j av a 2s.c o m*/ item.setChecked(true); return true; case R.id.item_sort_by_usage: mSort = "usage"; mPullToRefreshLayout.setRefreshing(true); refreshData(); item.setChecked(true); return true; } return super.onOptionsItemSelected(item); }
From source file:com.dogar.geodesic.activities.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); mOptionsMenu = menu;//from www .j av a 2 s .co m inflater.inflate(R.menu.main_activity_actions, menu); MenuItem delModeCheckbox = menu.findItem(R.id.delete_mode); delModeCheckbox.setChecked(SharedPreferencesUtils.isDeleteMode(this)); if (selectedMapID == -1) { return true; } MenuItem menuItem; switch (selectedMapID) { case R.id.map_terrain: menuItem = menu.findItem(R.id.map_terrain); menuItem.setChecked(true); bus.post(new MapTypeChangedEvent(GoogleMap.MAP_TYPE_TERRAIN)); break; case R.id.map_normal: menuItem = menu.findItem(R.id.map_normal); menuItem.setChecked(true); bus.post(new MapTypeChangedEvent(GoogleMap.MAP_TYPE_NORMAL)); break; case R.id.map_hybrid: menuItem = menu.findItem(R.id.map_hybrid); menuItem.setChecked(true); bus.post(new MapTypeChangedEvent(GoogleMap.MAP_TYPE_HYBRID)); break; } return super.onCreateOptionsMenu(menu); }