2

I have implemented the first row of tab.
Inside that tab i have another set of Tabs.
Specifically two more tabs.

Please refer to these images.

The Dog is Selected
The Picture above is the dog tab is selected.

enter image description here
The picture above is I want to select the Cat tab.
But unfortunately, the tab is not sliding properly.
its like its just a slowly scrolling.
but it should be on just one slide it should be on the cat tab.
My First layer of tab is inside Fragment.
The second row of tab is also in Fragment.

public class AdapterFragmentPagerItem extends FragmentStatePagerAdapter {
String[] pageTitle={"Do's","Dont's","First Aid"};
public AdapterFragmentPagerItem(FragmentManager fm) {
    super(fm);
}

@Override
public Fragment getItem(int position) {
    switch(position){
        case 0:
            return new FragmentDo();
        case 1:
            return new FragmentDonts();
        case 2:
            return new FragmentFirstAid();
    }
    return null;
}

@Override
public int getCount() {
    return 3;
}

@Override
public CharSequence getPageTitle(int position) {
    return pageTitle[position];
}


 }    

The above code is for the first image.

public class AdapterFragmentDos extends FragmentStatePagerAdapter {
String[] pageTitle = {"Dog", "Cat"};

public AdapterFragmentDos(FragmentManager fm) {
    super(fm);
}

@Override
public Fragment getItem(int position) {
    if(position==0){
        return new FragmentDonts();
    }else{
        return new FragmentFirstAid();
    }
}

@Override
public int getCount() {
    return 2;
}

@Override
public CharSequence getPageTitle(int position) {
    return pageTitle[position];
}
 }

And this is for the second image.

Charles Galvez
  • 1,100
  • 5
  • 19
  • 41
  • 2
    Rather than trying to make this work, I'd rethink the UI design. A tab in a tab is just not a good idea, as you're overloading gestures. – 323go Dec 11 '15 at 03:26
  • Okay i see. But what can you suggest for replacement with Tab? Well i have to select two which is if it is cat or dog. I dont like to use drop down since its not that good in my UI design – Charles Galvez Dec 11 '15 at 03:27
  • I don't know your requirements, but in a hierarchical app as this appears to be, work out your hierarchy first. Possibly have tabs just for the animals and then list the dos/don'ts/first aid as a segmented list below. – 323go Dec 11 '15 at 03:30
  • 1
    https://www.google.com/design/spec/components/tabs.html#tabs-usage under the guidelines, "Don't.Tabs should not be nested." you can try redefining your genres. do look at the guidelines for more ideas. – Angel Koh Dec 11 '15 at 03:32
  • That's a pretty good suggestion. But it will be too populated if I list all the dos/dont's/first aid at the same time. At the end i still need to use drop down for those three options. ? suggestions are very much welcome. thanks :) – Charles Galvez Dec 11 '15 at 03:32
  • 1
    you can try to put the top layers in a "navigation drawer", and use the tabs for the second layer? try to work it out on paper conceptually before putting it into codes. – Angel Koh Dec 11 '15 at 03:34
  • Layer you mean, If I clicked welfare in navigation drawer, it has an option of those three?(dos/dont's/first aid) am I right? – Charles Galvez Dec 11 '15 at 03:35

0 Answers0