0

Possible Duplicate:
How to implement horizontally scrollable tabs?

I would like to implement tabs in an app that essentially also allows swiping between two screens. A good example would be in the App section in the Google Play store. There are horizontal scrollable tabs up top and they move as the screen scrolls.

I am targeting Android 4.0 with this but need to make it backwards compatible.

I am obviously not asking anyone to write the entirety of code on this, I simply am looking for a tutorial somewhere, or advice on how to go about starting this. The Dev site show exactly what I want here: http://developer.android.com/design/building-blocks/tabs.html

But doesn't show HOW to do this (or at least make it visibly clear); it only says that's its good practice to do.

4
  • 1
    ^ That along with 104254252 other duplicates... Jun 26, 2012 at 15:45
  • Yes, but that is older implementation. I believe they have new recommendation now then what that shows? Jun 26, 2012 at 15:54
  • An older (???) implementation that works just fine and follow the rules. What's up with that about old code anyways? Jun 26, 2012 at 16:40
  • As in, I thought Google deprecated one method in favor of another. Happens all the time. Jun 26, 2012 at 19:59

2 Answers 2

1

take a look at this API, I use it and its very easy to implement

ViewPagerIndicator

2
  • Is this free for commercial use? Jan 17, 2013 at 7:22
  • 1
    its open source, plenty of applications in the market use it
    – tyczj
    Jan 17, 2013 at 15:21
0

This is usually done by using ViewPager class. In order to make it backward compatible take a look at the ActionBarSherlock project; there you will find examples on how to implement this kind of design pattern and make it work even on Android 1.6.

Also, as Alex said, you can take a look at the ViewPageIndicator project of the same developer if you don't want to care about an action bar.

4
  • ViewPagerIndicator is a possibility too, if the OP doesn't care about the action bar at all. Jun 26, 2012 at 15:41
  • You are right Alex. Thanks for pointing it out.
    – Cristian
    Jun 26, 2012 at 15:42
  • No point in importing the entire ActionBarSherlock library for no reason... that thing is huge :) Jun 26, 2012 at 15:45
  • I never even considered it, but for these two activities, I wouldn't necessarily need an ActionBar. Jun 26, 2012 at 15:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.