Search code examples
androidandroid-fragmentsfragment-tab-host

FragmentTabHost change tab name


After setting up my FragmentTabHost with addTab(mTabHost.newTabSpec(....)) I don't know ho to get the reference to the TabSpec.

All I need is to change the name of the tab (tabSpec.setIndicator("new name")) that I initially set with the mTabHost.newTabSpec method.

Thanks!


Solution

  • I find the answer myself. Simply calling this method on the fragmentTabHost object works:

    ((TextView((RelativeLayout)getTabWidget().getChildAt(tabIndex)).getChildAt(textIndex)).setText("NewTabText");