Modify tab indicator dynamically in Android

Posted by ZelluX on Stack Overflow See other posts from Stack Overflow or by ZelluX
Published on 2010-05-29T16:26:22Z Indexed on 2010/05/29 16:32 UTC
Read the original article Hit count: 649

Filed under:
|

My application needs to update tab indicator dynamically, I'm trying to do this by invoke TabSpec.setIndicator(), but it doesn't work. Here is my code:

In onCreate method of TabActivity:

tabHost = getTabHost(); 
TabSpec tabSpec = tabHost.newTabSpec("abc");
tabSpec.setIndicator("helloabc");
tabSpec.setContent(new MyViewFactory());
tabHost.addTab(tabSpec);

Now I need to change tab indicator to another string, for example, "xyz"

TabSpec tabSpec = MyTabActivity.getTabSpec();
tabSpec.setIndicator("xyz");

But it doesn't work. So I'd like to know how to change tab indicator after it is added to the tabhost? Many thanks.

© Stack Overflow or respective owner

Related posts about android

Related posts about tabhost