How do I change the background of an Android tab widget?

Viewed 83925

My class extends extends TabActivity

TabHost mTabHost =  getTabHost();

TabHost.TabSpec tab1 =mTabHost.newTabSpec("tab1");
TabHost.TabSpec tab2 =mTabHost.newTabSpec("tab2");

tab1 .setIndicator("title tab1");
tab2 .setIndicator("title tab2");
mTabHost.addTab(tab1);mTabHost.addTab(tab2);

TabHost.setCurrentTab(0 or 1)

Can anybody guide me how do I change the background image or color of selected tab?

6 Answers

What if you register for TabHost.OnTabChanged events and call mTabHost.getCurrentTabView() to get the View, then view.setBackgroundResource()?

Does this solve your problem? Basically calling setBackgroundDrawable on each tab view with a selector?

Related