List of usage examples for android.view MenuItem setChecked
public MenuItem setChecked(boolean checked);
From source file:io.demiseq.jetreader.activities.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.bind(this); db = new JumpDatabaseHelper(MainActivity.this); initToolbar();/*from www . j av a2 s . c o m*/ setupDrawerLayout(); progressBar.getIndeterminateDrawable().setColorFilter(Color.GRAY, PorterDuff.Mode.SRC_ATOP); categories = db.getAllCategories(); prefs = PreferenceManager.getDefaultSharedPreferences(this); searchBox.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { toggleSearch(true); int position = temp.indexOf(adapter.getItem(i)); Intent intent = new Intent(MainActivity.this, DetailActivity.class); intent.putExtra("manga", temp.get(position)); startActivity(intent); } }); searchBox.setOnClearListener(new CustomAutoCompleteTextView.OnClearListener() { @Override public void onClear() { toggleSearch(true); } }); boolean isOpenFromNotification = getIntent().getBooleanExtra("favorite", false); if (savedInstanceState == null && !isOpenFromNotification) { GetHotMangas(); new getAllMangas().execute(); } else if (isOpenFromNotification) { GetSubscription(); new getAllMangas().execute(); NavigationView view = (NavigationView) findViewById(R.id.navigation_view); Menu menu = view.getMenu(); for (int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); if (item.getItemId() == R.id.drawer_feeds) { savedMenuId = item.getItemId(); item.setChecked(true); } } } else { setTitle(savedInstanceState.getString("title")); mangas = savedInstanceState.getParcelableArrayList("list"); if (mangas != null) temp = new ArrayList<>(mangas); adapter = new SearchAdapter(getApplicationContext(), R.layout.search_dropdown_item, mangas); searchBox.setAdapter(adapter); NavigationView view = (NavigationView) findViewById(R.id.navigation_view); Menu menu = view.getMenu(); for (int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); if (item.getItemId() == savedInstanceState.getInt("menu")) { savedMenuId = savedInstanceState.getInt("menu"); item.setChecked(true); } } } }
From source file:com.owncloud.android.ui.fragment.contactsbackup.ContactListFragment.java
private void setSelectAllMenuItem(MenuItem selectAll, boolean checked) { selectAll.setChecked(checked); if (checked) { selectAll.setIcon(R.drawable.ic_select_none); } else {/*from w w w. j av a 2 s . c o m*/ selectAll.setIcon(R.drawable.ic_select_all); } }
From source file:com.kanchi.periyava.old.Activity.MainActivity.java
/** * Handles clicks on the navigation menu. *///from w w w . j a v a2 s. c om @Override public boolean onNavigationItemSelected(final MenuItem menuItem) { // update highlighted item in the navigation menu menuItem.setChecked(true); mNavItemId = menuItem.getItemId(); // allow some time after closing the drawer before performing real // navigation // so the user can see what is happening mDrawerLayout.closeDrawer(GravityCompat.START); mDrawerActionHandler.postDelayed(new Runnable() { @Override public void run() { navigate(menuItem.getItemId()); } }, DRAWER_CLOSE_DELAY_MS); return true; }
From source file:fiser.Activities.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.crear: Intent detailIntent = new Intent(this, SitioDetailActivity.class); Sitio sitio = new Sitio(); sitio.id = new Random().nextInt(Integer.MAX_VALUE); detailIntent.putExtra("sitio", sitio); startActivityForResult(detailIntent, PICK_CONTACT_REQUEST); return true; case R.id.settings: detailIntent = new Intent(this, SitioSettingsActivity.class); startActivity(detailIntent);/* ww w . ja v a2 s.c o m*/ return true; case R.id.cerca: item.setChecked(!item.isChecked()); listaRecargar(item.isChecked()); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.ichi2.anki.Statistics.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { // exit if mTaskHandler not initialized yet if (mTaskHandler == null) { return true; }/* www. ja va 2 s . com*/ switch (mTaskHandler.getStatType()) { case Stats.TYPE_MONTH: MenuItem monthItem = menu.findItem(R.id.item_time_month); monthItem.setChecked(true); break; case Stats.TYPE_YEAR: MenuItem yearItem = menu.findItem(R.id.item_time_year); yearItem.setChecked(true); break; case Stats.TYPE_LIFE: MenuItem lifeItem = menu.findItem(R.id.item_time_all); lifeItem.setChecked(true); break; } return super.onPrepareOptionsMenu(menu); }
From source file:io.jawg.osmcontributor.ui.activities.MapActivity.java
private void onSelectAllClick() { if (selectAllMenuItem.isChecked()) { poiTypesHidden.clear();/*from w w w . j a va 2 s. c o m*/ for (MenuItem filter : filtersItemList) { filter.setChecked(true); } } else { for (MenuItem filter : filtersItemList) { poiTypesHidden.add((long) filter.getItemId()); filter.setChecked(false); } } eventBus.post(new PleaseApplyPoiFilter(poiTypesHidden)); }
From source file:org.digitalcampus.oppia.activity.OppiaMobileActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initializeDagger();//w w w .j av a 2 s . c o m PreferenceManager.setDefaultValues(this, R.xml.prefs, false); prefs.registerOnSharedPreferenceChangeListener(this); // set preferred lang to the default lang if ("".equals(prefs.getString(PrefsActivity.PREF_LANGUAGE, ""))) { prefs.edit().putString(PrefsActivity.PREF_LANGUAGE, Locale.getDefault().getLanguage()).apply(); } messageContainer = this.findViewById(R.id.home_messages); messageText = (TextView) this.findViewById(R.id.home_message); messageButton = (Button) this.findViewById(R.id.message_action_button); courses = new ArrayList<>(); courseListAdapter = new CourseListAdapter(this, courses); courseList = (ListView) findViewById(R.id.course_list); courseList.setAdapter(courseListAdapter); //the alternative of registerForContextMenu(courseList); CourseContextMenuCustom courseMenu = new CourseContextMenuCustom(this); courseMenu.registerForContextMenu(courseList, this); courseList.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Course selectedCourse = courses.get(position); Intent i = new Intent(OppiaMobileActivity.this, CourseIndexActivity.class); Bundle tb = new Bundle(); tb.putSerializable(Course.TAG, selectedCourse); i.putExtras(tb); startActivity(i); } }); llNone = (LinearLayout) this.findViewById(R.id.no_courses); initialCourseListPadding = courseList.getPaddingTop(); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); // Initializing Drawer Layout and ActionBarToggle final DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer); navigationView = (NavigationView) findViewById(R.id.navigation_view); ((TextView) navigationView.getHeaderView(0).findViewById(R.id.drawer_user_fullname)) .setText(SessionManager.getUserDisplayName(this)); ((TextView) navigationView.getHeaderView(0).findViewById(R.id.drawer_username)) .setText(SessionManager.getUsername(this)); navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) { boolean result = onOptionsItemSelected(menuItem); menuItem.setChecked(false); drawerLayout.closeDrawers(); return result; } }); ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.open, R.string.close) { @Override public void onDrawerClosed(View drawerView) { // Code here will be triggered once the drawer closes as we dont want anything to happen so we leave this blank super.onDrawerClosed(drawerView); } @Override public void onDrawerOpened(View drawerView) { // Code here will be triggered once the drawer open as we dont want anything to happen so we leave this blank super.onDrawerOpened(drawerView); } }; //Setting the actionbarToggle to drawer layout drawerLayout.setDrawerListener(actionBarDrawerToggle); actionBarDrawerToggle.syncState(); }
From source file:com.irateam.vkplayer.activities.ListActivity.java
@Override public void onServiceConnected(ComponentName name, IBinder service) { playerService = ((PlayerService.PlayerBinder) service).getPlayerService(); playerController.setPlayerService(playerService); playerService.addPlayerEventListener(playerController); audioAdapter.setPlayerService(playerService); audioService.setPlayerService(playerService); Menu menu = navigationView.getMenu(); MenuItem item; if (playerService.getPlaylist().size() > 0) { item = menu.findItem(R.id.current_playlist); } else if (NetworkUtils.checkNetwork(this)) { item = menu.findItem(R.id.my_audio); } else {/*from w w w . j av a2s . c om*/ item = menu.findItem(R.id.cached_audio); } item.setChecked(true); onNavigationItemSelected(item); }
From source file:mroza.forms.ChooseProgramActivity.java
private void restoreSavedFilters() { if (savedState == null) return;/*from w w w.ja va 2 s . c om*/ boolean addedFilters = false; //restore filters if (savedState.containsKey("FILTERS")) { ArrayList<Integer> filters = savedState.getIntegerArrayList("FILTERS"); for (Integer filter : filters) { MenuItem item = menu.findItem(filter); selectedFilters.add(item); item.setChecked(true); } savedState.remove("FILTERS"); addedFilters = true; } //restore letter filter if (savedState.containsKey("LETTER_FILTER")) { letterFilter = menu.findItem(savedState.getInt("LETTER_FILTER")); savedState.remove("LETTER_FILTER"); addedFilters = true; } if (addedFilters) filterPrograms(); }
From source file:eu.pellerito.movies.fragment.BaseFragment.java
@Override public boolean onOptionsItemSelected(@NonNull MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. switch (item.getItemId()) { case R.id.menu_sort_popular: mOrder = String.valueOf(Costants.POPULAR); // update date updateUI();// w w w . ja va 2 s.c o m /* * click checked controls * */ if (item.isChecked()) item.setChecked(false); else item.setChecked(true); return true; case R.id.menu_sort_top_rated: mOrder = String.valueOf(Costants.TOP_RATED); // update date updateUI(); /* * click checked controls * */ if (item.isChecked()) item.setChecked(false); else item.setChecked(true); return true; default: return super.onOptionsItemSelected(item); } }