Vishesh Chandra
Vishesh Chandra

Reputation: 7071

Android, how to change the default color of Tab Widget in android

    public static void setTabColor(TabHost tabhost) {
    for(int i=0;i<tabhost.getTabWidget().getChildCount();i++)
    {
        tabhost.getTabWidget().getChildAt(i).setBackgroundColor(Color.BLACK); //unselected
    }
    tabhost.getTabWidget().getChildAt(tabhost.getCurrentTab()).setBackgroundColor(Color.BLUE); // selected
}

Please tell me where am i doing mistake...

i want to change the default background color of Tab Button, here only once in first Tab background color change but after that color is not changing when i am selecting other tab...

Please guide me, Thanks in advance...

Upvotes: 0

Views: 3668

Answers (1)

Labeeb Panampullan
Labeeb Panampullan

Reputation: 34823

only once in first Tab background color change but after that color is not changing when i am selecting other tab

May you are setting this only once (onCreate only )
Try by setting it on your setOnTabChangedListener like this

tabHost.setOnTabChangedListener(new OnTabChangeListener() {

@Override
public void onTabChanged(String tabId) {
setTabColor(tabHost);

}

Upvotes: 1

Related Questions