Reputation: 7071
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
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