resources will be based upon the new Locale, but ones in use will not,
for example the indicators of your TabHost. Having a TabHost with a
different language as for example the new content in the tab’s activity
looks bad.
Since the Android SDK doesn’t provide a way to change the indicator (title) of a tab
after creation, this is what I came up with myself:
Using java Syntax Highlighting
- /**
- * Updates the indicator (title) of a tab.
- *
- * @param index The index of the tab in your tabhost.
- * @param indicator The new indicator (title) for the tab.
- * @return Indicator updated with success.
- */
- public boolean setTabIndicator(int index, String indicator) {
- // The TabWidget of your TabHost.
- TabWidget widget = this.getTabHost().getTabWidget();
- // If the index is out of our widget's bounds, return false
- // to indicate no tabs were updated.
- if (index < 0 || index >= widget.getTabCount())
- return false;
- // A tab in your widget is a RelativeLayout.
- RelativeLayout tabView = (RelativeLayout) widget.getChildTabViewAt(index);
- // The RelativeLayout has 2 views. child-0 is an ImageView, which
- // represents the tab's icon. child-1 is a TextView, which represents
- // your tab's indicator (title).
- TextView tabTitle = (TextView) tabView.getChildAt(1);
- // Set the text of the TextView.
- tabTitle.setText(indicator);
- return true;
- }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


