Comment définir la couleur du texte dans la vue SetIndicator?
Question
Vous trouverez ci-dessous mon code pour l'activité TabView. Quelqu'un a une idée de la façon de définir TextColor dans la vue My SetIndicator pour 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"));
}
}
}
La solution
Vous pouvez utiliser TextView pour individu. Comme ça:
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);
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow