2

how to change specific tab color change on select event of Actionbar Tab i am using Actionbar Tab with view Pager tabs created programatically

Aditi K
  • 1,534
  • 5
  • 22
  • 43

2 Answers2

1

in styles.xml

<style name="AppTheme" parent="android:Theme.Holo">
    <item name="android:actionBarTabStyle">@style/MyTabStyle</item>
</style>

<style name="MyTabStyle" parent="android:Widget.ActionBar.TabView">
    <item name="android:background">@drawable/my_drawable</item>
</style>

or in code:

    TextView v = new TextView(...);
    v.setBackground(R.drawable.my_bg);
    ActionBar bar = getActionBar();
    ActionBar.Tab tab = bar.getTabAt(position);
    tab.setCustomView(v);
Nick Cardoso
  • 20,807
  • 14
  • 73
  • 124
1

to programatically change the tab's background color

 myTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener(){
  @Override
  public void onTabChanged(String tabId) {
   int tab = myTabHost.getCurrentTab();
    View view = myTabHost.getTabWidget().getChildAt(tab).setBackgroundColor(Color.CYAN);
  }
 });
Radheshyam Singh
  • 479
  • 3
  • 10