如何在导航抽屉中提供 SettingsActivity?
How to give SettingsActivity in Navigation Drawer?
Nooby 在这里再次提问。我做了很多研究以在导航抽屉中添加一个 'Settings' 行以转到我的 SettingsActivity。但未能获得良好的工作解决方案。有人请帮帮我。
private void setupDrawerContent(NavigationView navigationView) {
navigationView.setNavigationItemSelectedListener(
new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == R.id.tab_11) {
mViewPager.setCurrentItem(0);
} else if (menuItem.getItemId() == R.id.tab_22) {
mViewPager.setCurrentItem(1);
} else if (menuItem.getItemId() == R.id.tab_33) {
mViewPager.setCurrentItem(3);
} else if (menuItem.getItemId() == R.id.setting_nav) {
// What to add here ?
}
mDrawerLayout.closeDrawers();
return true;
}
});
这是你要求的仪式吗?
private void setupDrawerContent(NavigationView navigationView) {
navigationView.setNavigationItemSelectedListener(
new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == R.id.tab_11) {
mViewPager.setCurrentItem(0);
} else if (menuItem.getItemId() == R.id.tab_22) {
mViewPager.setCurrentItem(1);
} else if (menuItem.getItemId() == R.id.tab_33) {
mViewPager.setCurrentItem(3);
} else if (menuItem.getItemId() == R.id.setting_nav) {
Intent nextIntent = new Intent(getApplicationContext(), settingActivity.class);
startActivity(nextIntent);
}
mDrawerLayout.closeDrawers();
return true;
}
});
Nooby 在这里再次提问。我做了很多研究以在导航抽屉中添加一个 'Settings' 行以转到我的 SettingsActivity。但未能获得良好的工作解决方案。有人请帮帮我。
private void setupDrawerContent(NavigationView navigationView) {
navigationView.setNavigationItemSelectedListener(
new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == R.id.tab_11) {
mViewPager.setCurrentItem(0);
} else if (menuItem.getItemId() == R.id.tab_22) {
mViewPager.setCurrentItem(1);
} else if (menuItem.getItemId() == R.id.tab_33) {
mViewPager.setCurrentItem(3);
} else if (menuItem.getItemId() == R.id.setting_nav) {
// What to add here ?
}
mDrawerLayout.closeDrawers();
return true;
}
});
这是你要求的仪式吗?
private void setupDrawerContent(NavigationView navigationView) {
navigationView.setNavigationItemSelectedListener(
new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == R.id.tab_11) {
mViewPager.setCurrentItem(0);
} else if (menuItem.getItemId() == R.id.tab_22) {
mViewPager.setCurrentItem(1);
} else if (menuItem.getItemId() == R.id.tab_33) {
mViewPager.setCurrentItem(3);
} else if (menuItem.getItemId() == R.id.setting_nav) {
Intent nextIntent = new Intent(getApplicationContext(), settingActivity.class);
startActivity(nextIntent);
}
mDrawerLayout.closeDrawers();
return true;
}
});