I want to make a design like the first photo
always using navigation drawer, but when i select another fragment from this menu (nav drawer) the tab bar will change for something like this
Imagine in my navigation drawer i have 3 fragments for my menu: Numbers, Animals, Letters. So when I tap on Numbers will show the first one, if I tap on Animals will show the second one which is different than the first one, and I if I tap on Letters will show something different.
How can I do that?
I trying with an adapter
public class tabpagerAdapter extends FragmentStatePagerAdapter {
String[] tabarray = new String[]{"Elephant","Tiger","Bear"};
Integer tabnumber = 3;
public tabpagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public CharSequence getPageTitle(int position) {
return tabarray[position];
}
@Override
public Fragment getItem(int position) {
switch (position)
{
case 0:
one one1 = new one();
return one1;
case 1:
two two2 = new two();
return two2;
case 2:
three three3 = new three();
return three3;
}
return null;
}
@Override
public int getCount() {
return tabnumber;
}
}
MainActivity:
tabpagerAdapter Tabpageradapter = new tabpagerAdapter(getSupportFragmentManager());
Pager.setAdapter(Tabpageradapter);
tabLayout.setupWithViewPager(Pager);
but it only works if it is the same tab bar for all the fragments in my navigation drawer
Comments
Post a Comment