Pablo M.
Pablo M.

Reputation: 53

ViewPagerIndicator tabs to become ActionBarSherlock spinner in landscape

I'm using both ViewPagerIndicator and ActionBarSherlock in my projects.

Is there an easy way to make ViewPagerIndicator tabs become a spinner in ActionBarSherlock when the device is rotated to landscape? You know, so as to make more room available for the rest of content.

Do I have to do all the work manually capturing the event @onConfigurationChanged?

Upvotes: 1

Views: 1191

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007276

If this is really what you want, rather than using ViewPagerIndicator, you should be using tabs in the action bar. Those will automatically convert to a drop-down list in the action bar in different circumstances. Here is a sample project demonstrating tying ViewPager to action bar tabs: https://github.com/commonsguy/cw-omnibus/tree/master/ViewPager/TabPager

Note, though, that there is a bug in Android, reproduced in ActionBarSherlock for compatibility, that will mean that swipe events in the ViewPager will not be reflected in the action bar when in drop-down list mode.

If you really want to use ViewPagerIndicator instead of action bar tabs, not only are you on your own, but you will suffer from the same bug that I mentioned in the previous paragraph.

Personally, I recommend using tabs (whether PagerTabStrip or ViewPagerIndicator) in all cases, rather than switching back and forth.

Upvotes: 2

Related Questions