现用了一tabhost,选中某选项时,会跟上一背景图,实现代码如下
tab_indicator.xml
<?xml version="1.0" encoding="UTF-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_focused="false"
android:state_selected="false"
android:state_pressed="false"
android:drawable="@drawable/tab_unselected" />
<item
android:state_focused="false"
android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/onselect"   
/></selector>
现需:如果要在选中某选项时,还要再把选中项的文字的颜色变成白色(默认是黑色),
(我在上面的文件中加入android:color 没用)
怎么实现呀 thanks

解决方案 »

  1.   

    <TextView
      android:textColor="@color/tab_textview_color"/>tab_textview_color.xml代码:<?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item
    android:state_selected="true"
    android:color="@color/tab_textview_pressed" />
    <!-- not selected -->
    <item android:color="@color/tab_textview_normal" />
    </selector>
    tab_textview_pressed   tab_textview_normal 颜色值
      

  2.   

    多谢,我用另一方法解决了
    public void onTabChanged(String tabId) {
    //tabId值为要切换到的tab页的索引位置
    int tabID = Integer.valueOf(tabId);
    for (int i = 0; i < tabWidget.getChildCount(); i++)
    {
    if (i == tabID) 
    {
    tabWidget.getChildAt(Integer.valueOf(i));
    final TextView textView = (TextView) tabWidget.getChildAt(Integer.valueOf(i)).findViewById(R.id.title);
    textView.setTextColor(0xffFEFFFF);

    else 
    {
    tabWidget.getChildAt(Integer.valueOf(i));
    final TextView textView = (TextView) tabWidget.getChildAt(Integer.valueOf(i)).findViewById(R.id.title);
    textView.setTextColor(0xff767674);
    }
    }
    }
      

  3.   

    楼主问一下  
    final TextView textView = (TextView) tabWidget.getChildAt(Integer.valueOf(i)).findViewById(R.id.title);R.id.title 是哪的title,