Pregunta

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!

¿Fue útil?

Solución

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

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

Otros consejos

I think this is a more straight way to get the thing done:

((TextView) mTabHost.getCurrentTabView().findViewById(android.R.id.title))
.setText(yourTitle);

Whoever wrote this should have defined a setTabText(int position, String text) method, otherwise who would know they have a text view id'ed android.R.id.title? Or if they already had, please enlighten me.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top