1

I am getting back into android after taking a break from it for a while. However from reading it seems like if you use tabhost (or even actionbar) you cannot add tab icons on top of the tab text.

i.e you cant do this tabspec.setIndicator("Tab1",drawableIcon) It will just show the text with no icon. Is there anyway you can add a tab with the icon on top of the text with the new ICS theme?

PS. I am doing fragments with tabhost. In case you were wondering if i was using tabhost the old way (with activities)

Also, I know I can make my own theme to mimick ICS but I dont want to do that.

thunderousNinja
  • 3,510
  • 9
  • 37
  • 49
  • Looks like duplicate for http://stackoverflow.com/questions/10745092/icon-in-tab-is-not-showing-up – Tushar Aug 15 '12 at 14:55

1 Answers1

1

To get the image to show

    int imageViewIndex = 1;
    if (ifICS) {
        imageViewIndex = 0;
    }

    ViewGroup idView = (ViewGroup) mTabHost.getTabWidget().getChildAt(INDEX);
    ImageView imageView = (ImageView) idView.getChildAt(imageViewIndex);
    imageView.setImageResource(R.drawable...);

then if you set the image View after the tabhost is made the image will be displayed

Mark Hetherington
  • 1,612
  • 14
  • 24