我有一个带有导航抽屉和tabview和viewPager的活动。 我想根据导航抽屉中的选择在tabview中打开一些片段。这就是我根据选择导航到片段的方式
mNavigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
mDrawerLayout.closeDrawers();
if (menuItem.getItemId() == R.id.ap) {
FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.containerView, new FpFragment()).commit();
}
if (menuItem.getItemId() == R.id.vfp) {
FragmentTransaction xfragmentTransaction = mFragmentManager.beginTransaction();
xfragmentTransaction.replace(R.id.containerView, new VeryFinFrag()).commit();
}
有可能吗?