List of usage examples for android.view MenuItem isChecked
public boolean isChecked();
From source file:click.kobaken.rxirohaandroid_sample.view.activity.MainActivity.java
private void initBottomNavigationView() { binding.bottomNavigation/*from w ww . ja v a 2 s. c o m*/ .setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { allClearNavigationMenuChecked(); if (!item.isChecked()) { binding.navigation.getMenu().getItem(0).setChecked(true); switch (item.getItemId()) { case R.id.action_receipt: Log.d(TAG, "onNavigationItemSelected: Receiver"); binding.toolbar.setTitle(getString(R.string.receive)); switchFragment(assetReceiveFragment, AssetReceiveFragment.TAG); break; case R.id.action_wallet: Log.d(TAG, "onNavigationItemSelected: Wallet"); binding.toolbar.setTitle(getString(R.string.wallet)); switchFragment(walletFragment, WalletFragment.TAG); break; case R.id.action_sender: Log.d(TAG, "onNavigationItemSelected: Sender"); binding.toolbar.setTitle(getString(R.string.send)); switchFragment(assetSenderFragment, AssetSenderFragment.TAG); break; } } else { Log.d(TAG, "onNavigationItemSelected: Top?!"); final FragmentManager manager = getSupportFragmentManager(); MainActivityListener listener = (MainActivityListener) manager .findFragmentById(R.id.container); listener.onNavigationItemClicked(); } return true; } }); }
From source file:cn.zhangls.android.weibo.ui.message.mention.MentionActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { onBackPressed();// ww w . j av a 2s . c o m return true; } else if (item.isChecked()) { return super.onOptionsItemSelected(item); } switch (item.getItemId()) { case R.id.menu_ac_msg_all_weibo: mWeiboListType = WeiboListType.ALL_WEIBO; break; case R.id.menu_ac_msg_following_weibo: mWeiboListType = WeiboListType.FOLLOWING_WEIBO; break; case R.id.menu_ac_msg_original_weibo: mWeiboListType = WeiboListType.ORIGINAL_WEIBO; break; case R.id.menu_ac_msg_all_comment: mWeiboListType = WeiboListType.ALL_COMMENT; break; case R.id.menu_ac_msg_following_comment: mWeiboListType = WeiboListType.FOLLOWING_COMMENT; break; } item.setChecked(true); onRefresh(); showProgressDialog(); return true; }
From source file:com.emotion.emotioncontrol.MainActivity.java
@Override public boolean onOptionsItemSelected(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. int id = item.getItemId(); if (id == R.id.action_show_drawer_icon) { boolean checked = item.isChecked(); item.setChecked(!checked);// w w w. j a v a 2 s .c o m setLauncherIconEnabled(!checked); return true; } return super.onOptionsItemSelected(item); }
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// w ww . java 2s . c o m public boolean onMenuItemClick(MenuItem item) { item.setChecked(!item.isChecked()); showArchivedMessages = item.isChecked(); downloadData(); downloadArchivedData(); return false; } }); }
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 w w .j a v a2s . c om*/ public boolean onMenuItemClick(MenuItem item) { item.setChecked(!item.isChecked()); showArchivedMessages = item.isChecked(); downloadData(); downloadArchivedData(); return false; } }); }
From source file:com.pepperonas.truthordare.MainActivity.java
private void initNavView() { mNavView = (NavigationView) findViewById(R.id.navigation_view); mNavView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override/*from ww w . j a va 2 s . c o m*/ public boolean onNavigationItemSelected(MenuItem menuItem) { menuItem.setChecked(menuItem.isChecked()); mDrawerLayout.closeDrawers(); return selectNavViewItem(menuItem); } }); // selecting the first item selectNavViewItem(getNavigationView().getMenu().getItem(0).getSubMenu().getItem(0)); }
From source file:com.f2prateek.dfg.ui.activities.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { // views aren't toggled automatically, so we // just use the opposite of the state we're in case R.id.menu_checkbox_glare: updateGlareSetting(!item.isChecked()); return true; case R.id.menu_checkbox_shadow: updateShadowSetting(!item.isChecked()); return true; case R.id.menu_checkbox_blur_background: updateBlurBackgroundSetting(!item.isChecked()); return true; case R.id.menu_checkbox_color_background: updateColorBackgroundSetting(!item.isChecked()); return true; case R.id.menu_match_device: analytics.track("Match Device Menu Item Clicked"); Device device = deviceProvider.find(windowManager); if (device == null) { analytics.track("Device Not Matched"); Snackbar.make(pager, R.string.no_matching_device, Snackbar.LENGTH_LONG).show(); } else {/*from w w w. j a va2 s. c om*/ pager.setCurrentItem(pagerAdapter.getDeviceIndex(device)); } return true; case R.id.menu_about: analytics.track("About Menu Item Clicked"); final AboutFragment fragment = new AboutFragment(); fragment.show(getFragmentManager(), "about"); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.xfininity.m.modest_account_man.MainActivity.java
private void setupDrawerContent(NavigationView navigationView, ViewPager viewPager) { final ViewPager vp = viewPager; navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override//w ww. ja va 2s .c om public boolean onNavigationItemSelected(MenuItem menuItem) { Adapter adapter = new Adapter(getSupportFragmentManager()); //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 mDrawerLayout.closeDrawers(); //Check to see which item was being clicked and perform appropriate action switch (menuItem.getItemId()) { //Replacing the main content with ContentFragment Which is our Inbox View; case R.id.screen: Toast.makeText(getApplicationContext(), "Inbox Selected", Toast.LENGTH_SHORT).show(); return true; // For rest of the options we just show a toast on click case R.id.nav_overview: toolbar.setTitle("Overview"); adapter.addFragment(new DashBoard_Fragment(), "DashBoard"); adapter.addFragment(new DashBoard_Fragment(), "Billing"); adapter.addFragment(new DashBoard_Fragment(), "Manage"); vp.setAdapter(adapter); tabLayout.setupWithViewPager(vp); return true; case R.id.nav_shop: toolbar.setTitle("Shop"); adapter.addFragment(new DashBoard_Fragment(), "Category 4"); adapter.addFragment(new DashBoard_Fragment(), "Category 5"); adapter.addFragment(new DashBoard_Fragment(), "Category 6"); vp.setAdapter(adapter); tabLayout.setupWithViewPager(vp); return true; case R.id.nav_support: toolbar.setTitle("Support"); Toast.makeText(getApplicationContext(), "Drafts Selected", Toast.LENGTH_SHORT).show(); return true; case R.id.nav_account: toolbar.setTitle("Account"); Toast.makeText(getApplicationContext(), "All Mail Selected", Toast.LENGTH_SHORT).show(); adapter.addFragment(new DashBoard_Fragment(), "DashBoard"); adapter.addFragment(new Billing_Fragment(), "Billing"); adapter.addFragment(new Manage_Fragment(), "Manage"); vp.setAdapter(adapter); tabLayout.setupWithViewPager(vp); return true; case R.id.nav_search: toolbar.setTitle("Search"); Toast.makeText(getApplicationContext(), "Trash Selected", Toast.LENGTH_SHORT).show(); return true; case R.id.nav_l_chat: toolbar.setTitle("Live Chat"); Toast.makeText(getApplicationContext(), "Spam Selected", Toast.LENGTH_SHORT).show(); return true; default: toolbar.setTitle("My Account"); Toast.makeText(getApplicationContext(), "Somethings Wrong", Toast.LENGTH_SHORT).show(); return true; } // return true; } }); }
From source file:io.github.protino.codewatch.ui.NavigationDrawerActivity.java
@Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { item.setChecked(!item.isChecked()); String text;//from ww w. j a v a 2 s. com switch (item.getItemId()) { case R.id.dashboard: text = getString(R.string.dashboard_title); replaceFragment(new DashboardFragment(), text); break; case R.id.goals: text = getString(R.string.goals_title); replaceFragment(new GoalsFragment(), text); break; case R.id.achievements: text = getString(R.string.achievements_title); replaceFragment(new AchievementFragment(), text); break; case R.id.leaderboards: text = getString(R.string.leaderboards); replaceFragment(new LeaderboardFragment(), text); break; case R.id.projects: text = getString(R.string.projects_title); replaceFragment(new ProjectsFragment(), text); break; case R.id.settings: text = getString(R.string.settings_title); replaceFragment(new SettingsFragment(), text); break; default: break; } drawerLayout.closeDrawers(); return true; }
From source file:com.ota.updates.activities.MainActivity.java
/** * Setup listeners for the NavigationView drawer so that when items are selected some actions * can be take//from w ww. java 2 s . com * * @param navigationView The NavigationView we are listening for * @param drawerLayout The Drawer Layout containing the items */ private void setupNavigationViewOnItemSelected(NavigationView navigationView, final DrawerLayout drawerLayout) { //Setting Navigation View Item Selected Listener to handle the item click of the navigation menu navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { // This method will trigger on item Click of navigation menu @Override 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(); //Check to see which item was being clicked and perform appropriate action switch (menuItem.getItemId()) { //Replacing the main content with ContentFragment Which is our Inbox View; case R.id.ota_updates: checkForUpdate(); return true; // For rest of the options we just show a toast on click case R.id.ota_versions: loadFragment(new AddonsFragment()); return true; case R.id.ota_addons: loadFragment(new AddonsFragment()); return true; case R.id.rom_donate: Toast.makeText(getApplicationContext(), "Drafts Selected", Toast.LENGTH_SHORT).show(); return true; case R.id.app_about: loadFragment(new AboutFragment()); return true; case R.id.app_github: String appGitHubUrl = mContext.getResources().getString(R.string.app_github_url); Utils.openWebsite(mContext, appGitHubUrl); default: return true; } } }); }