I’ve just updated my app to use an ActionBar with navigation tabs and the splitActionBarWhenNarrow option, integrated with ViewPager to allow swiping between tabs. The home icon and title in the bar are disabled. It is functionally working on all configurations, but in one case it doesn’t act as I would expect.
When on a smartphone in portrait config, the Action Bar splits with the tabs in the top bar and the menu/action items in the bottom bar. Of course I can select a page by tapping a tab, and when I swipe from page to page the tab selection highlight (underbar) moves to the selected tab. So far so good.
When I turn the device into the landscape position, I now get a single Action Bar at the top. The action and overflow menu icons are at the right, and Android has turned my tabs into a dropdown selector on the left side. This works OK when I use the selector to change pages, but when I swipe from page to page the selector does not change to indicate the current tab.
My code of course does not change depending on configuration, and I set breakpoints to show that onPageSelected is called, which calls bar.setSelectedNavigationItem, causing onTabSelected to be called in turn. So the expected actions are taking place, but the selector in the dropdown does not change.
Any ideas what is going on?
(For what it’s worth, in landscape position on a tablet, I get yet another variant: a single Action Bar with my tabs on the left and action items on the right. In this case, the tab highlight correctly follows when swiping.)
Correct.
Action bar tabs are sucktastic.
Specifically, you are running into this bug. If I am reading the Gerrit page correctly, Jake’s patch (or a modified version thereof) has been accepted, so perhaps Android 4.3/5.0 will work properly in this regard.