I am using tabHost in my application and the requirement is that when any tab is selected the color of tab indicator should change ,I referred this example How to set Tab View Indicator background color in Android but i didn't understood Here is my code:
TabHost tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Reusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, HomePage.class);
// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost.newTabSpec("tabOne");
spec.setContent(intent);
spec.setIndicator("Home");
tabHost.addTab(spec);
// Squash the tab a little bit horizontally
tabHost.getTabWidget().getChildAt(0).getLayoutParams().height = 40;
tabHost.getTabWidget().getChildAt(0).getLayoutParams().width = 50;
// Bump the text size upll.getChildAt(0);
// Do the same for the other tabs
intent = new Intent().setClass(this, MoteIt.class);
spec = tabHost.newTabSpec("tabTwo");
spec.setContent(intent);
spec.setIndicator("moteit");
tabHost.addTab(spec);
tabHost.getTabWidget().getChildAt(1).getLayoutParams().height = 40;
intent = new Intent().setClass(this, Lifeline.class);
spec = tabHost.newTabSpec("tabThree");
spec.setContent(intent);
spec.setIndicator("lifeline");
tabHost.addTab(spec);
tabHost.getTabWidget().getChildAt(2).getLayoutParams().height = 40;
intent = new Intent().setClass(this, CircleOfTrust.class);
spec = tabHost.newTabSpec("tabfour");
spec.setContent(intent);
spec.setIndicator("Cot");
tabHost.addTab(spec);
tabHost.getTabWidget().getChildAt(3).getLayoutParams().height = 40;
intent = new Intent().setClass(this, Search.class);
spec = tabHost.newTabSpec("tabFive");
spec.setContent(intent);
spec.setIndicator("Search");
tabHost.addTab(spec);
tabHost.getTabWidget().getChildAt(4).getLayoutParams().height = 40;
tabHost.getTabWidget().setStripEnabled(true);
tabHost.setCurrentTab(0);
提前致谢