2011-11-14 58 views
0

我正在開發一個Android項目。在我的項目中,我使用標籤佈局。它工作正常,但所有選項卡背景是黑色的,當我選擇任何選項卡時,該選項卡背景變爲淺棕色。是否可以給定製顏色?如何更改標籤背景?

我的XML文件

<?xml version="1.0" encoding="utf-8"?> 
<TabHost 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@android:id/tabhost" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 

> 

<LinearLayout 
android:id="@+id/LinearLayout01" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" 

> 

<TabWidget 
android:id="@android:id/tabs" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 

></TabWidget> 

<FrameLayout 
android:id="@android:id/tabcontent" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 

></FrameLayout> 


</LinearLayout> 



</TabHost> 

我的Java代碼

Resources res = getResources(); 
    TabHost tb=getTabHost(); 
    Intent i; 
    TabHost.TabSpec spec; 




    spec = tb.newTabSpec("mee").setIndicator ("home").setContent(i); 



    tb.addTab(spec); 


    spec=tb.newTabSpec("contacts").setIndicator("search").setContent(i); 
    tb.addTab(spec); 

回答