0

我在我的項目中的標籤,我只是想知道,如果你可以改變橙色當您單擊選項卡到其他顏色,你desire.i想改變它變成其他顏色,你可以改變它只通過XML或編程?可以在選定的選項卡橙色是改變成其他顏色

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:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 
     <TabWidget 
      android:id="@android:id/tabs" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" /> 
     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"/> 
    </LinearLayout> 
</TabHost> 

選擇:

<!-- Active tab --> 
<item android:state_selected="true" android:state_focused="false" 
    android:state_pressed="false" android:drawable="@drawable/tab_bg_selected" /> 
<!-- Inactive tab --> 
<item android:state_selected="false" android:state_focused="false" 
    android:state_pressed="false" android:drawable="@drawable/tab_bg_unselected" /> 

+0

您更改選擇標籤顏色是正確的。 – Yugesh

+0

組選擇到到烏爾標籤佈局 –

+0

是在我的例子中,當前選項卡的顏色是灰色的另一個標籤是黑色的,當我點擊其他選項卡中的橙色顯得我想把它換成其他顏色,我有一個選擇,我將發佈但它不工作 – Giant

回答

0

這是從不同的答案採取了一些代碼,應該工作:

View mIndicator = inflater.inflate(R.layout.tab_indicator_holo, 
          mTabHost.getTabWidget(), false); // this will inflate a layout, you can use whatever layout you want 
TextView title1 = (TextView) mIndicator.findViewById(android.R.id.title); //so we add a title 

title1.setText("TAB1"); // we bind the title 

mTabsAdapter.addTab(mTabHost.newTabSpec("TAB1").setIndicator(mIndicator), F_GetGames.class, null); // we bind the inflated layout 

Source

+0

讓我讀就可以了謝謝 – Giant

+0

我看過,但我對如何誇大你可以給例如不知道? – Giant

+0

請點擊[編輯]鏈接並將代碼直接發佈到您的問題中,然後刪除您的評論。 – idmean

相關問題