本文整理了Java中android.support.design.widget.NavigationView.inflateMenu()
方法的一些代码示例,展示了NavigationView.inflateMenu()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NavigationView.inflateMenu()
方法的具体详情如下:
包路径:android.support.design.widget.NavigationView
类名称:NavigationView
方法名:inflateMenu
暂无
代码示例来源:origin: daquexian/chaoli-forum-for-android-2
@Override
public void onPropertyChanged(Observable observable, int i) {
binding.navigationView.getMenu().clear();
binding.navigationView.inflateMenu(viewModel.isLoggedIn.get() ? R.menu.menu_navigation : R.menu.menu_navigation_no_login);
}
});
代码示例来源:origin: opengit/AndroidNewWidgetsDemo
private void configViews() {
// 设置显示Toolbar
setSupportActionBar(mToolbar);
// 设置Drawerlayout开关指示器,即Toolbar最左边的那个icon
ActionBarDrawerToggle mActionBarDrawerToggle =
new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.open, R.string.close);
mActionBarDrawerToggle.syncState();
mDrawerLayout.setDrawerListener(mActionBarDrawerToggle);
//给NavigationView填充顶部区域,也可在xml中使用app:headerLayout="@layout/header_nav"来设置
mNavigationView.inflateHeaderView(R.layout.header_nav);
//给NavigationView填充Menu菜单,也可在xml中使用app:menu="@menu/menu_nav"来设置
mNavigationView.inflateMenu(R.menu.menu_nav);
// 自己写的方法,设置NavigationView中menu的item被选中后要执行的操作
onNavgationViewMenuItemSelected(mNavigationView);
// 初始化ViewPager的适配器,并设置给它
mViewPagerAdapter = new MyViewPagerAdapter(getSupportFragmentManager(), mTitles, mFragments);
mViewPager.setAdapter(mViewPagerAdapter);
// 设置ViewPager最大缓存的页面个数
mViewPager.setOffscreenPageLimit(5);
// 给ViewPager添加页面动态监听器(为了让Toolbar中的Title可以变化相应的Tab的标题)
mViewPager.addOnPageChangeListener(this);
mTabLayout.setTabMode(MODE_SCROLLABLE);
// 将TabLayout和ViewPager进行关联,让两者联动起来
mTabLayout.setupWithViewPager(mViewPager);
// 设置Tablayout的Tab显示ViewPager的适配器中的getPageTitle函数获取到的标题
mTabLayout.setTabsFromPagerAdapter(mViewPagerAdapter);
// 设置FloatingActionButton的点击事件
mFloatingActionButton.setOnClickListener(this);
}
代码示例来源:origin: nvllsvm/Audinaut
private void populateTabs() {
drawerList.getMenu().clear();
drawerList.inflateMenu(R.menu.drawer_navigation);
MenuItem offlineMenuItem = drawerList.getMenu().findItem(R.id.drawer_offline);
if (Util.isOffline(this)) {
if (lastSelectedPosition == 0 || lastSelectedPosition == R.id.drawer_library) {
String newFragment = "Artist";
lastSelectedPosition = getDrawerItemId(newFragment);
drawerItemSelected(newFragment);
}
offlineMenuItem.setTitle(R.string.main_online);
} else {
offlineMenuItem.setTitle(R.string.main_offline);
}
if (lastSelectedPosition != 0) {
MenuItem item = drawerList.getMenu().findItem(lastSelectedPosition);
if (item != null) {
item.setChecked(true);
}
}
drawerHeaderToggle.setImageResource(R.drawable.main_select_server_dark);
showingTabs = true;
}
代码示例来源:origin: Michenux/YourAppIdea
protected void showSecondaryMenu() {
this.mHeaderArrowOpened = true;
this.getNavigationView().getMenu().clear();
this.getNavigationView().inflateMenu(R.menu.navigation_drawer_secondarymenu);
this.mPrimaryMenuDisplayed = false;
}
代码示例来源:origin: Michenux/YourAppIdea
protected void showPrimaryMenu() {
this.mHeaderArrowOpened = false;
this.getNavigationView().getMenu().clear();
this.getNavigationView().inflateMenu(R.menu.navigation_drawer_menu);
this.mPrimaryMenuDisplayed = true;
}
代码示例来源:origin: Michenux/YourAppIdea
protected void createMenu(@MenuRes int menu) {
this.getNavigationView().getMenu().clear();
this.getNavigationView().inflateMenu(menu);
setupHeaderView();
}
代码示例来源:origin: pedroSG94/rtmp-rtsp-stream-client-java
navigationView = findViewById(R.id.nv_rtp);
navigationView.inflateMenu(R.menu.options_rtmp);
actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.rtsp_streamer,
R.string.rtsp_streamer) {
代码示例来源:origin: pedroSG94/rtmp-rtsp-stream-client-java
private void prepareOptionsMenuViews() {
drawerLayout = findViewById(R.id.activity_custom);
navigationView = findViewById(R.id.nv_rtp);
navigationView.inflateMenu(R.menu.options_rtsp);
actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.rtsp_streamer,
R.string.rtsp_streamer) {
代码示例来源:origin: WangDaYeeeeee/Mysplash
private void initView() {
this.handler = new SafeHandler<>(this);
if (ThemeManager.getInstance(this).isLightTheme()) {
nav.inflateMenu(R.menu.activity_main_drawer);
} else {
nav.inflateMenu(R.menu.activity_main_drawer);
}
nav.setCheckedItem(drawerPresenter.getCheckedItemId());
nav.setNavigationItemSelectedListener(this);
if (AuthManager.getInstance().isAuthorized() && Mysplash.hasNode()) {
nav.getMenu().getItem(1).setVisible(true);
} else {
nav.getMenu().getItem(1).setVisible(false);
}
View header = nav.getHeaderView(0);
header.setOnClickListener(this);
this.navAvatar = ButterKnife.findById(header, R.id.container_nav_header_avatar);
this.appIcon = ButterKnife.findById(header, R.id.container_nav_header_appIcon);
ImageHelper.loadResourceImage(this, appIcon, R.drawable.ic_launcher);
this.navTitle = ButterKnife.findById(header, R.id.container_nav_header_title);
this.navSubtitle = ButterKnife.findById(header, R.id.container_nav_header_subtitle);
this.navButton = ButterKnife.findById(header, R.id.container_nav_header_button);
navButton.setOnClickListener(this);
}
内容来源于网络,如有侵权,请联系作者删除!