Hi I am adding tabs dynamically in my Android application, In that I just want to change the text color in the tab. I tried several methods like applying styles. But none works for me. Can anyone tell me the ways to achieve this.
for (int k = 0; k < i; k++) {
// final int tabCount = bar.getTabCount();
final String text = unit[k];
bar.addTab(bar.newTab()
.setText(text)
.setTabListener(new TabListener(new TabContentFragment(text))));
//bar.getCustomView().setBackgroundColor(R.color.tabcolor);
}
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);
To change the text color of a dynamically added tab, just add this line in your theme.
<item name="android:actionBarTabTextStyle">@style/tabtextcolor</item>