4

In my app I have a Sherlock ActionBar with spinner navigation ("ActionBar.NAVIGATION_MODE_LIST"). In one activity I have two fragments which shall be switchable via tabs. What I did now, was to put the fragment loading into a ViewPager ("android.support.v4.view.ViewPager") together with a "android.support.v4.view.PagerTabStrip" for switching between the fragment tabs.

My problem is now, that these are horizontal scrollable tabs. Same seems to be with Jake Whartons viewpageindicator (viewpagerindicator.com). But what I want is two fixed tabs beside each other. How is that possible with the the support library or with the viewpageindicator?

For wording see http://developer.android.com/design/building-blocks/tabs.html

Sebastian Engel
  • 3,500
  • 32
  • 30

1 Answers1

0

But what I want is two fixed tabs beside each other. How is that possible with the the support library or with the viewpageindicator?

You will have to write your own indicator. Or, you can use action bar tabs in concert with a ViewPager, but that will conflict with your existing action bar navigation and cannot be relied upon to give you tabs in any case.

Since the tabs will only meaningfully scroll if they are too big for the screen, personally I would not worry about this issue.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • 1
    Yes that's what I did now. I implemented a ViewPager indicator based on a LinearLayout which contains two TextViews. An OnTouchListener on each TextView handles the "setCurrentItem()" on the ViewPager. That looks and works fine and this seems to be the only possibility. – Sebastian Engel Dec 03 '12 at 10:33
  • @SebastianEngel would it be ok with you to post the code you implemented? I would like to see how you implemented it. Thanks! – TomTaila Jan 02 '15 at 22:56
  • @AttackOnTitom It's been two years since I worked on that. So I just copied together some of the code that belongs to it. Hope it helps anyway. https://gist.github.com/SebastianEngel/9099e004e8b2c3b4c364 – Sebastian Engel Jan 14 '15 at 20:45