Avoid building/rebuilding the action tabs.

Doing this on a tab callback confuses the action bar rendering.

Bug: 5288508
Change-Id: Ifbba2c2a30f5def04ec36ea2395c0d6da2bdf00d
This commit is contained in:
Ben Komalo 2011-09-21 13:06:40 -07:00
parent 4fde113af6
commit 8506afff28

View File

@ -1801,11 +1801,12 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
if (shouldUseActionTabs()) {
// Tab-based mode switching.
if (actionBar.getTabCount() > 0) {
actionBar.removeAllTabs();
selectActionTab(mAction);
} else {
createAndAddTab(R.string.reply_action, ACTION_REPLY);
createAndAddTab(R.string.reply_all_action, ACTION_REPLY_ALL);
createAndAddTab(R.string.forward_action, ACTION_FORWARD);
}
createAndAddTab(R.string.reply_action, ACTION_REPLY);
createAndAddTab(R.string.reply_all_action, ACTION_REPLY_ALL);
createAndAddTab(R.string.forward_action, ACTION_FORWARD);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
} else {
@ -1912,6 +1913,17 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
return tab;
}
private void selectActionTab(final String action) {
final ActionBar actionBar = getActionBar();
for (int i = 0, n = actionBar.getTabCount(); i < n; i++) {
ActionBar.Tab tab = actionBar.getTabAt(i);
if (action.equals(tab.getTag())) {
actionBar.selectTab(tab);
return;
}
}
}
private boolean shouldUseActionTabs() {
return getResources().getBoolean(R.bool.message_compose_action_tabs);
}