tabhost.getCurrentTabView().setBackgroundColor(Color.CYAN); //设置默认选中状态的背景
 tabhost.setOnTabChangedListener(new OnTabChangeListener() {               @Override              
        public void onTabChanged(String tabId) {
              for(int i = 0; i < tabWidge.getChildCount(); i++) {                                View tabView = tabWidge.getChildAt(i);                          if(tabhost.getCurrentTab() == i) {                           tabView.setBackgroundColor(Color.CYAN);                              } else {                                    tabView.setBackgroundColo(Color.BLACK));     //未选中的颜色         
                    }                
                        }           
                 }          
        });  

解决方案 »

  1.   

    你好,谢谢你的回复,按照你的方法做了,还是没有效果,我这个选项卡点击的时候是显示自己定义的图片,我发现有tabHost.getCurrentTabView().setBackgroundResource(R.drawable.home_btn_bg_s)方法,试了也不行,不知道是不是与自定义的图标有关系
      

  2.   

    问题解决了!!获取到要设置选择状态的RadioButton对象,然后调用button的setchecked方法
      

  3.   

    你这 ,也不说清楚,Tabhost还掺和了RadioButton对象
      

  4.   

    介意LZ不要再使用TabHost,这个在工作中是不用的
      

  5.   

    不要再使用TabHost?那一般都使用什么呢??请教下
      

  6.   

    刚开始接触,所以不是很清楚我还以为tabhost就应该是与radiobutton一起用呢
      

  7.   

    3楼说的对.
                    mTabHost.setCurrentTab(0);
    home_radio = (RadioButton) findViewById(R.id.home_radio);
    home_radio.setChecked(true);
      

  8.   

    这样不行啊,没有setChecked方法。
      

  9.   

    有了,为毛直接(RadioButton) findViewById(R.id.home_radio).这样找不到呢
      

  10.   

    tabHost.setOnTabChangedListener(new OnTabChangeListener() {
    int[] hots=new int[]{R.drawable.red1,R.drawable.red1,R.drawable.red,R.drawable.red,R.drawable.red};
    @Override
    public void onTabChanged(String tabId) {

    for (int i = 0; i < tabWidget.getChildCount(); i++) {
    View vvv = tabWidget.getChildAt(i);
    if (tabHost.getCurrentTab() == i) {
    vvv.setBackgroundResource(hots[i]);
    } else {
    vvv.setBackgroundResource(R.drawable.match_bg_score);
    }
    }
    }
    });