How to change android tab text on the fly?
Wow. Okay this was a pain. Apparently TabWidget does something funky with RelativeLayout and everytime I tried to do anything with radek-k's solution it was blowing up with a RelativeLayout error. So basically the work around is the following. It also allows you to change the font, font size, font color, etc.
TabWidget vTabs = getTabWidget();
RelativeLayout rLayout = (RelativeLayout) vTabs.getChildAt(tabIndex);
((TextView) rLayout.getChildAt(textIndex)).setText("NewTabText");
or in one line...
((TextView)((RelativeLayout)getTabWidget().getChildAt(tabIndex)).getChildAt(textIndex)).setText("NewTabText");
where "textIndex" is the index of the text field. In this case it is 1. If the tab has an icon or custom modifications the index could change.
Thanks again to radek-k. You definitely got me pointed in the right direction.
try this easiest way which works for me :
tabLayout.getTabAt(index).setText("TabName");