Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法在android中更改Tabhost的背景色_Android_Android Tabhost - Fatal编程技术网

无法在android中更改Tabhost的背景色

无法在android中更改Tabhost的背景色,android,android-tabhost,Android,Android Tabhost,最近,我制作了一个利用Tabhost的简单应用程序。 但是,我无法设置它的颜色。我已经在下面设置了示例代码。如何才能将颜色添加到当前代码中?如果我能得到小费或帮助,那将是一个很大的帮助 Resources res = getResources(); TabHost tabHost = getTabHost(); TabSpec spec; Intent intent; //tabHost.getTabWidget().get

最近,我制作了一个利用Tabhost的简单应用程序。 但是,我无法设置它的颜色。我已经在下面设置了示例代码。如何才能将颜色添加到当前代码中?如果我能得到小费或帮助,那将是一个很大的帮助

   Resources res = getResources();
        TabHost tabHost = getTabHost();
        TabSpec spec;
        Intent intent;

        //tabHost.getTabWidget().getChildAt(0).setBackgroundColor(Color.parseColor("#C0392B"));


        intent = new Intent().setClass(this, SecondActivity.class);

        spec = tabHost.newTabSpec("Second Activity").setIndicator(res.getString(R.string.act_second), res.getDrawable(R.drawable.ic_tab)).setContent(intent);
        tabHost.addTab(spec);

我在我的
tabChanged
方法中设置
tabHost
的颜色,如下所示:

for( int i=0;i<mTabHost.getTabWidget().getChildCount();i++)
    {
        mTabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#7392B5"));
    }
mTabHost.getTabWidget().getChildAt(mTabHost.getCurrentTab()).setBackgroundColor(Color.parseColor("#4E4E9C"));

for(int i=0;i如果当前选项卡或其他选项卡未被选中,您想为它们指定颜色吗?好的,我想将颜色设置为当前选项卡和所选选项卡。谢谢!我会尝试!