As seen all the time 3 tabs on PagerTabStrip?

I have an android app that is trying to implement android PagerTabStrip on a ViewPager.I has three tabs 1) Tab1 2) Tab2 and 3) Tab3. When Tab1 is selected you will only see Tab1 -> Tab2 (pic_01). When selecting Tab2, it will display Tab1 -> Tab2 -> Tab3 (pic_02). When Tab3 is selected, it shows Tab2 -> Tab3 (pic_03). But I want all 3 tabs to be visible at the same time. For example, when Tab1 is selected, it will be Tab3 -> Tab1 -> Tab2. The same as when selecting Tab2, it will be ab1 → Tab2 → Tab3. And when Tab3 is selected then it will be Tab2 -> Tab3 -> Tab1.My try cod below which I am implementing.

   viewPager = (ViewPager) findViewById(R.id.pager);        
    mPagerTabStrip = (PagerTabStrip)findViewById(R.id.PagerTab);
    mPagerTabStrip.setScrollContainer(true);
    // Set the ViewPagerAdapter into ViewPager
    viewPager.setAdapter(new ViewPagerAdapter(getSupportFragmentManager()));

      

ViewPagerAdapter is the FragmentPagerAdapter class.

public class ViewPagerAdapter extends FragmentPagerAdapter {

final int PAGE_COUNT = 3;
// Tab Titles
private String tabtitles[] = new String[] { "Tab1", "Tab2", "Tab3" };
Context context;

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

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

@Override
public Fragment getItem(int position) {

    Log.w("position", "are:"+position);
    switch (position) {


        // Open FragmentTab1.java
    case 0:
        FragmentTab1 fragmenttab1 = new FragmentTab1();
        return fragmenttab1;

        // Open FragmentTab2.java
    case 1:
        FragmentTab2 fragmenttab2 = new FragmentTab2();
        return fragmenttab2;

        // Open FragmentTab3.java
    case 2:
        FragmentTab3 fragmenttab3 = new FragmentTab3();
        return fragmenttab3;
    }
    return null;
}

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

      

}

enter image description here

enter image description here

enter image description here

Actually, I want all three tabs to be visible in the same way as pic_02.Is this possible? Please help me. (Thanks everyone)

+3


source to share


1 answer


Per this answer to a similar question I don't think it is PagerTabStrip

possible with using to show all three tabs at the same time (except when the second tab is, of course). It looks like you have to use ActionBar

or flip your own tab strip.



0


source







All Articles