0

下面是我的 TabView 活动代码。任何人都知道如何在我的 SetIndicator 视图中为 TabView 设置 TextColor?

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"));
       }

    }
}
4

1 回答 1

1

您可以将 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);
}
于 2011-05-09T12:56:00.037 回答