本文整理了Java中android.support.design.widget.NavigationView.getMenu()
方法的一些代码示例,展示了NavigationView.getMenu()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NavigationView.getMenu()
方法的具体详情如下:
包路径:android.support.design.widget.NavigationView
类名称:NavigationView
方法名:getMenu
暂无
代码示例来源:origin: naman14/Timber
public void run() {
navigationView.getMenu().findItem(R.id.nav_library).setChecked(true);
Fragment fragment = new MainFragment();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.fragment_container, fragment).commitAllowingStateLoss();
}
};
代码示例来源:origin: naman14/Timber
navigationView.getMenu().findItem(R.id.nav_library).setIcon(R.drawable.library_music);
navigationView.getMenu().findItem(R.id.nav_playlists).setIcon(R.drawable.playlist_play);
navigationView.getMenu().findItem(R.id.nav_queue).setIcon(R.drawable.music_note);
navigationView.getMenu().findItem(R.id.nav_folders).setIcon(R.drawable.ic_folder_open_black_24dp);
navigationView.getMenu().findItem(R.id.nav_nowplaying).setIcon(R.drawable.bookmark_music);
navigationView.getMenu().findItem(R.id.nav_settings).setIcon(R.drawable.settings);
navigationView.getMenu().findItem(R.id.nav_about).setIcon(R.drawable.information);
navigationView.getMenu().findItem(R.id.nav_donate).setIcon(R.drawable.payment_black);
} else {
navigationView.getMenu().findItem(R.id.nav_library).setIcon(R.drawable.library_music_white);
navigationView.getMenu().findItem(R.id.nav_playlists).setIcon(R.drawable.playlist_play_white);
navigationView.getMenu().findItem(R.id.nav_queue).setIcon(R.drawable.music_note_white);
navigationView.getMenu().findItem(R.id.nav_folders).setIcon(R.drawable.ic_folder_open_white_24dp);
navigationView.getMenu().findItem(R.id.nav_nowplaying).setIcon(R.drawable.bookmark_music_white);
navigationView.getMenu().findItem(R.id.nav_settings).setIcon(R.drawable.settings_white);
navigationView.getMenu().findItem(R.id.nav_about).setIcon(R.drawable.information_white);
navigationView.getMenu().findItem(R.id.nav_donate).setIcon(R.drawable.payment_white);
navigationView.getMenu().removeItem(R.id.nav_donate);
代码示例来源:origin: naman14/Timber
public void run() {
navigationView.getMenu().findItem(R.id.nav_folders).setChecked(true);
Fragment fragment = new FoldersFragment();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.hide(getSupportFragmentManager().findFragmentById(R.id.fragment_container));
transaction.replace(R.id.fragment_container, fragment).commit();
}
};
代码示例来源:origin: naman14/Timber
public void run() {
navigationView.getMenu().findItem(R.id.nav_playlists).setChecked(true);
Fragment fragment = new PlaylistFragment();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.hide(getSupportFragmentManager().findFragmentById(R.id.fragment_container));
transaction.replace(R.id.fragment_container, fragment).commit();
}
};
代码示例来源:origin: naman14/Timber
public void run() {
navigationView.getMenu().findItem(R.id.nav_queue).setChecked(true);
Fragment fragment = new QueueFragment();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.hide(getSupportFragmentManager().findFragmentById(R.id.fragment_container));
transaction.replace(R.id.fragment_container, fragment).commit();
}
};
代码示例来源:origin: TeamNewPipe/NewPipe
private void changeService(MenuItem item) {
drawerItems.getMenu().getItem(ServiceHelper.getSelectedServiceId(this)).setChecked(false);
ServiceHelper.setSelectedServiceId(this, item.getItemId());
drawerItems.getMenu().getItem(ServiceHelper.getSelectedServiceId(this)).setChecked(true);
}
代码示例来源:origin: TeamNewPipe/NewPipe
private void toggleServices() {
servicesShown = !servicesShown;
drawerItems.getMenu().removeGroup(R.id.menu_services_group);
drawerItems.getMenu().removeGroup(R.id.menu_tabs_group);
drawerItems.getMenu().removeGroup(R.id.menu_options_about_group);
if(servicesShown) {
showServices();
} else {
try {
showTabs();
} catch (Exception e) {
ErrorActivity.reportUiError(this, e);
}
}
}
代码示例来源:origin: JZ-Darkal/AndroidHttpCapture
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
if (isVisibleToUser) {
// initProxyWebView();
((MainActivity) getActivity()).navigationView.getMenu().getItem(0).setChecked(true);
}
}
代码示例来源:origin: pockethub/PocketHub
private void setUpNavigationMenu() {
MenuItem organizationContainer = navigationView.getMenu().findItem(R.id.navigation_organizations);
if (organizationContainer.hasSubMenu()) {
SubMenu organizationsMenu = organizationContainer.getSubMenu();
for (int i = 1; i < orgs.size(); i++) {
User organization = orgs.get(i);
if (organizationsMenu.findItem(organization.id().intValue()) == null) {
MenuItem organizationMenuItem = organizationsMenu.add(Menu.NONE, organization.id().intValue(), Menu.NONE, organization.name() != null ? organization.name() : organization.login());
organizationMenuItem.setIcon(R.drawable.ic_github_organization_black_24dp);
//Because of tinting the real image would became a grey block
//avatars.bind(organizationMenuItem, organization);
menuItemOrganizationMap.put(organizationMenuItem, organization);
}
}
} else {
throw new IllegalStateException("Menu item " + organizationContainer + " should have a submenu");
}
}
代码示例来源:origin: TeamNewPipe/NewPipe
private void showServices() {
serviceArrow.setImageResource(R.drawable.ic_arrow_up_white);
for(StreamingService s : NewPipe.getServices()) {
final String title = s.getServiceInfo().getName() +
(ServiceHelper.isBeta(s) ? " (beta)" : "");
drawerItems.getMenu()
.add(R.id.menu_services_group, s.getServiceId(), ORDER, title)
.setIcon(ServiceHelper.getIcon(s.getServiceId()));
}
drawerItems.getMenu().getItem(ServiceHelper.getSelectedServiceId(this)).setChecked(true);
}
代码示例来源:origin: TeamNewPipe/NewPipe
drawerItems.getMenu()
.add(R.id.menu_tabs_group, kioskId, ORDER, KioskTranslator.getTranslatedKioskName(ks, this))
.setIcon(KioskTranslator.getKioskIcons(ks, this));
drawerItems.getMenu()
.add(R.id.menu_tabs_group, ITEM_ID_SUBSCRIPTIONS, ORDER, R.string.tab_subscriptions)
.setIcon(ThemeHelper.resolveResourceIdFromAttr(this, R.attr.ic_channel));
drawerItems.getMenu()
.add(R.id.menu_tabs_group, ITEM_ID_FEED, ORDER, R.string.fragment_whats_new)
.setIcon(ThemeHelper.resolveResourceIdFromAttr(this, R.attr.rss));
drawerItems.getMenu()
.add(R.id.menu_tabs_group, ITEM_ID_BOOKMARKS, ORDER, R.string.tab_bookmarks)
.setIcon(ThemeHelper.resolveResourceIdFromAttr(this, R.attr.ic_bookmark));
drawerItems.getMenu()
.add(R.id.menu_tabs_group, ITEM_ID_DOWNLOADS, ORDER, R.string.downloads)
.setIcon(ThemeHelper.resolveResourceIdFromAttr(this, R.attr.download));
drawerItems.getMenu()
.add(R.id.menu_tabs_group, ITEM_ID_HISTORY, ORDER, R.string.action_history)
.setIcon(ThemeHelper.resolveResourceIdFromAttr(this, R.attr.history));
drawerItems.getMenu()
.add(R.id.menu_options_about_group, ITEM_ID_SETTINGS, ORDER, R.string.settings)
.setIcon(ThemeHelper.resolveResourceIdFromAttr(this, R.attr.settings));
drawerItems.getMenu()
.add(R.id.menu_options_about_group, ITEM_ID_ABOUT, ORDER, R.string.tab_about)
.setIcon(ThemeHelper.resolveResourceIdFromAttr(this, R.attr.info));
代码示例来源:origin: TeamNewPipe/NewPipe
drawerItems.getMenu()
.add(R.id.menu_tabs_group, kioskId, 0, KioskTranslator.getTranslatedKioskName(ks, this))
.setIcon(KioskTranslator.getKioskIcons(ks, this));
drawerItems.getMenu()
.add(R.id.menu_tabs_group, ITEM_ID_SUBSCRIPTIONS, ORDER, R.string.tab_subscriptions)
.setIcon(ThemeHelper.resolveResourceIdFromAttr(this, R.attr.ic_channel));
drawerItems.getMenu()
.add(R.id.menu_tabs_group, ITEM_ID_FEED, ORDER, R.string.fragment_whats_new)
.setIcon(ThemeHelper.resolveResourceIdFromAttr(this, R.attr.rss));
drawerItems.getMenu()
.add(R.id.menu_tabs_group, ITEM_ID_BOOKMARKS, ORDER, R.string.tab_bookmarks)
.setIcon(ThemeHelper.resolveResourceIdFromAttr(this, R.attr.ic_bookmark));
drawerItems.getMenu()
.add(R.id.menu_tabs_group, ITEM_ID_DOWNLOADS, ORDER, R.string.downloads)
.setIcon(ThemeHelper.resolveResourceIdFromAttr(this, R.attr.download));
drawerItems.getMenu()
.add(R.id.menu_tabs_group, ITEM_ID_HISTORY, ORDER, R.string.action_history)
.setIcon(ThemeHelper.resolveResourceIdFromAttr(this, R.attr.history));
drawerItems.getMenu()
.add(R.id.menu_options_about_group, ITEM_ID_SETTINGS, ORDER, R.string.settings)
.setIcon(ThemeHelper.resolveResourceIdFromAttr(this, R.attr.settings));
drawerItems.getMenu()
.add(R.id.menu_options_about_group, ITEM_ID_ABOUT, ORDER, R.string.tab_about)
.setIcon(ThemeHelper.resolveResourceIdFromAttr(this, R.attr.info));
代码示例来源:origin: pockethub/PocketHub
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
int itemId = menuItem.getItemId();
if (itemId == R.id.navigation_home) {
switchFragment(new HomePagerFragment(), org);
getSupportActionBar().setTitle(getString(R.string.app_name));
return true;
} else if (itemId == R.id.navigation_gists) {
switchFragment(new GistsPagerFragment(), null);
getSupportActionBar().setTitle(menuItem.getTitle());
return true;
} else if (itemId == R.id.navigation_issue_dashboard) {
switchFragment(new IssueDashboardPagerFragment(), null);
getSupportActionBar().setTitle(menuItem.getTitle());
return true;
} else if (itemId == R.id.navigation_bookmarks) {
switchFragment(new FilterListFragment(), null);
getSupportActionBar().setTitle(menuItem.getTitle());
return true;
} else if (itemId == R.id.navigation_log_out) {
logout();
return false;
} else if (menuItemOrganizationMap.containsKey(menuItem)) {
switchFragment(new HomePagerFragment(), menuItemOrganizationMap.get(menuItem));
navigationView.getMenu().findItem(R.id.navigation_home).setChecked(true);
return false;
} else {
throw new IllegalStateException("MenuItem " + menuItem + " not known");
}
}
代码示例来源:origin: JohnPersano/SuperToasts
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
final DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
final ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(
this, drawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close) {
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
// Stop animating the navigation icon
super.onDrawerSlide(drawerView, 0);
}
};
drawerLayout.addDrawerListener(actionBarDrawerToggle);
actionBarDrawerToggle.syncState();
final NavigationView navigationView = (NavigationView) findViewById(R.id.navigation_view);
navigationView.setNavigationItemSelectedListener(this);
navigationView.setCheckedItem(R.id.navigation_drawer_supertoast);
// setCheckedItem() does not actually call the associated listener
if (savedInstanceState == null) this.onNavigationItemSelected(navigationView.getMenu().getItem(0));
}
代码示例来源:origin: JZ-Darkal/AndroidHttpCapture
navigationView.getMenu().getItem(0).setChecked(true);
代码示例来源:origin: xinghongfei/LookLook
nevigationId = SharePreferenceUtil.getNevigationItem(this);
if (nevigationId != -1) {
currentMenuItem = navView.getMenu().findItem(nevigationId);
currentMenuItem = navView.getMenu().findItem(R.id.zhihuitem);
currentMenuItem = navView.getMenu().findItem(R.id.zhihuitem);
MenuItem item = navView.getMenu().findItem(R.id.nav_theme);
mThemeSwitch = (SwitchCompat) MenuItemCompat.getActionView(item).findViewById(R.id.view_switch);
mThemeSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
代码示例来源:origin: chrisk44/Hijacker
static void refreshDrawer(){
navigationView.getMenu().findItem(currentFragment).setChecked(true);
actionBar.setTitle(navTitlesMap.get(currentFragment));
}
static String getManuf(String mac){
代码示例来源:origin: ac-pm/Inspeckage
private void hideItem()
{
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
Menu nav_Menu = navigationView.getMenu();
nav_Menu.findItem(R.id.nav_auth).setVisible(false);
}
@Override
代码示例来源:origin: chenyangcun/MaterialDesignExample
@Override
public void onClick(View v) {
switchToBlog();
mDrawerLayout.closeDrawers();
mNavigationView.getMenu().getItem(1).setChecked(true);
}
});
代码示例来源:origin: kaku2015/ColorfulNews
private void initNightModeSwitch() {
if (this instanceof NewsActivity || this instanceof PhotoActivity) {
MenuItem menuNightMode = mBaseNavView.getMenu().findItem(R.id.nav_night_mode);
SwitchCompat dayNightSwitch = (SwitchCompat) MenuItemCompat
.getActionView(menuNightMode);
setCheckedState(dayNightSwitch);
setCheckedEvent(dayNightSwitch);
}
}
内容来源于网络,如有侵权,请联系作者删除!