如何更改一个Android标签控件的背景是什么?控件、如何更改、背景、标签

2023-09-11 12:36:48 作者:抬起头往前走。

我的类扩展扩展TabActivity

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?

推荐答案

如果您注册什么的TabHost.OnTabChanged事件,并呼吁mTabHost.getCurrentTabView()来获取视图,然后view.setBackgroundResource()?

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