public void addTab(ActionBar.Tab tab, boolean setSelected) { TabView tabView = createTabView(tab, false); mTabLayout.addView(tabView, new IcsLinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1)); if (mTabSpinner != null) { ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged(); } if (setSelected) { tabView.setSelected(true); } if (mAllowCollapse) { requestLayout(); } }
@Override public void setCurrentItem(int item) { if (mViewPager == null) { throw new IllegalStateException("ViewPager has not been bound."); } mSelectedTabIndex = item; mViewPager.setCurrentItem(item); final int tabCount = mTabLayout.getChildCount(); for (int i = 0; i < tabCount; i++) { TabView child = (TabView) mTabLayout.getChildAt(i); final boolean isSelected = (i == item); child.setSelected(isSelected); /* * Set text color in case of selected */ if (isSelected) { child.setTextColor(Color.rgb(65, 65, 65)); animateToTab(item); } else child.setTextColor(Color.rgb(120, 120, 120)); } }