Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - Update indicator of tab after creation.

Update indicator of tab after creation.

Quickly share your Android Code Snippets here...

Update indicator of tab after creation.

Postby RickB » Sat Jan 01, 2011 2:07 pm

When a user updates his/her Locale while running your application, all new
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:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         /**
  2.          * Updates the indicator (title) of a tab.
  3.          *
  4.          * @param index The index of the tab in your tabhost.
  5.          * @param indicator The new indicator (title) for the tab.
  6.          * @return Indicator updated with success.
  7.          */
  8.         public boolean setTabIndicator(int index, String indicator) {
  9.                 // The TabWidget of your TabHost.
  10.                 TabWidget widget = this.getTabHost().getTabWidget();
  11.  
  12.                 // If the index is out of our widget's bounds, return false
  13.                 // to indicate no tabs were updated.
  14.                 if (index < 0 || index >= widget.getTabCount())
  15.                         return false;
  16.  
  17.                 // A tab in your widget is a RelativeLayout.
  18.                 RelativeLayout tabView = (RelativeLayout) widget.getChildTabViewAt(index);
  19.  
  20.                 // The RelativeLayout has 2 views. child-0 is an ImageView, which
  21.                 // represents the tab's icon. child-1 is a TextView, which represents
  22.                 // your tab's indicator (title).
  23.                 TextView tabTitle = (TextView) tabView.getChildAt(1);
  24.  
  25.                 // Set the text of the TextView.
  26.                 tabTitle.setText(indicator);
  27.                 return true;
  28.         }
  29.  
  30.  
Parsed in 0.013 seconds, using GeSHi 1.0.8.4
RickB
Once Poster
Once Poster
 
Posts: 1
Joined: Fri Aug 27, 2010 4:54 pm
Location: Netherlands

Top

Return to Code Snippets for Android

Who is online

Users browsing this forum: No registered users and 10 guests