Friday, February 1, 2013

[android-developers] Unexpected Action Bar Behavior

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.)

Doug Gordon
GHCS Software

--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment