如何在SetIndicator视图中设置文本颜色?
问题描述:
下面是我的代码为TabView活动。任何人都有想法如何设置TabView的我的SetIndicator视图中的TextColor?如何在SetIndicator视图中设置文本颜色?
public class TabView extends TabActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources res=getResources();
TabHost tabhost=getTabHost();
TabHost.TabSpec restab;
Intent intent;
intent=new Intent().setClass(this, Home.class);
restab=tabhost.newTabSpec("Home").setIndicator("Home",res.getDrawable(R.drawable.home)).setContent(intent);
tabhost.addTab(restab);
intent=new Intent().setClass(this, Search.class);
restab=tabhost.newTabSpec("Search").setIndicator("Search",res.getDrawable(R.drawable.search_icon1)).setContent(intent);
tabhost.addTab(restab);
intent=new Intent().setClass(this, Back.class);
restab=tabhost.newTabSpec("Back").setIndicator("Back",res.getDrawable(R.drawable.back_icon)).setContent(intent);
tabhost.addTab(restab);
for(int i=0;i<tabhost.getTabWidget().getChildCount();i++)
{
tabhost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#CCCCCC"));
}
}
}
答
您可以对个人使用TextView。像这样:
for(int i = 0; i < tabhost.getTabWidget().getChildCount(); i++) {
tabhost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#CCCCCC"));
TextView textView = (TextView) tabWidget.getChildAt(i).findViewById(android.R.id.title);
textView.setTextColor(Color.BLACK);
}
这真的会帮助我很多谢谢回复 – Herry 2011-05-09 12:56:55