List of usage examples for android.view MenuItem setChecked
public MenuItem setChecked(boolean checked);
From source file:io.github.hidroh.materialistic.SearchActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getGroupId() == R.id.menu_sort_group) { item.setChecked(true); sort(item.getItemId() == R.id.menu_sort_recent); return true; }//from w w w .j ava 2 s .co m return super.onOptionsItemSelected(item); }
From source file:in.lovelacetech.qrib.ui.BaseActivity.java
@Override public boolean onNavigationItemSelected(MenuItem item) { final int itemId = item.getItemId(); item.setChecked(true); mMainLayout.closeDrawers();/*from www .j av a 2s. c om*/ return false; }
From source file:com.commonsware.android.assist.mo.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.fixed) { item.setChecked(!item.isChecked()); if (item.isChecked()) { if (pager.getCurrentItem() > 2) { pager.setCurrentItem(2); }/*from w w w. j a v a 2s . c o m*/ pager.postDelayed(new Runnable() { @Override public void run() { adapter.setPageCount(3); adapter.notifyDataSetChanged(); } }, 100); } else { adapter.setPageCount(10); adapter.notifyDataSetChanged(); } return (true); } return (super.onOptionsItemSelected(item)); }
From source file:com.example.android.materialdesigncodelab.presentation.activities.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);//from w ww . j av a2s . c om ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager); setupViewPager(viewPager); TabLayout tabs = (TabLayout) findViewById(R.id.tabs); tabs.setupWithViewPager(viewPager); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); drawerLayout = (DrawerLayout) findViewById(R.id.drawer); ActionBar supportActionBar = getSupportActionBar(); if (supportActionBar != null) { supportActionBar.setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp); supportActionBar.setDisplayHomeAsUpEnabled(true); } navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { menuItem.setChecked(true); drawerLayout.closeDrawers(); return true; } }); }
From source file:com.zprogrammer.tool.ui.EditActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { MenuItem item = menu.findItem(R.id.action_highlight); item.setChecked(data.getjing()); return super.onPrepareOptionsMenu(menu); }
From source file:fr.utc.frixx.payutc_android.MainActivity.java
private void setupDrawerContent(NavigationView navigationView) { navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override// ww w.j a v a 2 s . c om public boolean onNavigationItemSelected(MenuItem menuItem) { menuItem.setChecked(true); switch (menuItem.getItemId()) { case R.id.nav_block_account: System.out.println("Bloquer mon compte"); break; case R.id.nav_disconnect: System.out.println("Dconnexion"); UserData.manager().reset(); MainActivity.this.finish(); break; } //mDrawerLayout.closeDrawers(); return true; } }); }
From source file:com.loopj.android.http.sample.Redirect302Sample.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { MenuItem menuItemEnableRedirects = menu.findItem(0); if (menuItemEnableRedirects != null) menuItemEnableRedirects.setChecked(enableRedirects); MenuItem menuItemEnableRelativeRedirects = menu.findItem(1); if (menuItemEnableRelativeRedirects != null) menuItemEnableRelativeRedirects.setChecked(enableRelativeRedirects); MenuItem menuItemEnableCircularRedirects = menu.findItem(2); if (menuItemEnableCircularRedirects != null) menuItemEnableCircularRedirects.setChecked(enableCircularRedirects); return super.onPrepareOptionsMenu(menu); }
From source file:com.vrem.wifianalyzer.navigation.NavigationMenuView.java
public void setCurrentNavigationMenu(@NonNull NavigationMenu navigationMenu) { this.currentNavigationMenu = navigationMenu; Menu menu = navigationView.getMenu(); for (int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); item.setCheckable(navigationMenu.ordinal() == i); item.setChecked(navigationMenu.ordinal() == i); }//from w w w .j a v a2 s. c o m }
From source file:com.geodoer.bodymotiondetector.MainActivity.java
private void setupDrawerContent(NavigationView navigationView) { navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override/* w w w .j a v a 2 s. c o m*/ public boolean onNavigationItemSelected(MenuItem menuItem) { menuItem.setChecked(true); mDrawerLayout.closeDrawers(); Intent thisIntent = new Intent(); switch (menuItem.getItemId()) { case R.id.navm_home: thisIntent.setClass(getApplication(), MainActivity.class); startActivity(thisIntent); break; case R.id.navm_messages: break; case R.id.navm_discussion: // break; case R.id.navm_friends: // break; } return true; } }); }
From source file:com.tutosandroidfrance.designsupporttest.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.inject(this); setupWindowAnimations();//from w w w .j a v a 2 s . c om //dfinir la toolbr en tant qu'actionbar setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, 0, 0); drawerLayout.setDrawerListener(drawerToggle); navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { menuItem.setChecked(true); drawerLayout.closeDrawers(); return true; } }); //on remplit notre viewpager, comme notre habitude viewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) { @Override public Fragment getItem(int position) { return RecyclerViewFragment.newInstance(); } @Override public CharSequence getPageTitle(int position) { return "Tab " + position; } @Override public int getCount() { return 4; } }); //indique au tablayout quel est le viewpager couter tabLayout.setupWithViewPager(viewPager); }