How do I set the text color in the SetIndicator view?
Question
Below is my Code For the TabView Activity. Any one have idea how to set TextColor in the my SetIndicator view for TabView?
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"));
}
}
}
Solution
You can use TextView for individual. Like this:
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);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow