Merge "Don't crash if R.styleable int array is null" into ub-contactsdialer-a-dev
diff --git a/src/com/android/contacts/common/list/ViewPagerTabs.java b/src/com/android/contacts/common/list/ViewPagerTabs.java
index 6ee1448..dd1fd9a 100644
--- a/src/com/android/contacts/common/list/ViewPagerTabs.java
+++ b/src/com/android/contacts/common/list/ViewPagerTabs.java
@@ -219,8 +219,9 @@
         tabView.setOnLongClickListener(new OnTabLongClickListener(position));
 
         tabView.setPadding(mSidePadding, 0, mSidePadding, 0);
-        mTabStrip.addView(tabView, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
-                LayoutParams.MATCH_PARENT, 1));
+
+        mTabStrip.addView(tabView, position, new LinearLayout.LayoutParams(
+                LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1));
 
         // Default to the first child being selected
         if (position == 0) {
@@ -229,6 +230,17 @@
         }
     }
 
+    /**
+     * Refresh a tab at a certain index by removing it and reconstructing it.
+     *
+     * @param index The index of the tab view we wish to update.
+     */
+    public void updateTab(int index) {
+        View view = mTabStrip.getChildAt(index);
+        mTabStrip.removeView(view);
+        addTab(mPager.getAdapter().getPageTitle(index), index);
+    }
+
     @Override
     public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
         position = getRtlPosition(position);