0

I'm trying to fill the TabHost with TabSpec's, all is fine but the icons inserted with setIndicator(text,drawable) are not shown. I tried using my own pics, as well as the ones from android - none worked.

Here's my code:

tabs = (TabHost)findViewById( android.R.id.tabhost );
tabs.setup();

TabHost.TabSpec spec;
spec = tabs.newTabSpec( "destinationTab" )
           .setContent( R.id.destinationTab )
           .setIndicator( getString( R.string.enter_target ), getResources().getDrawable( android.R.drawable.ic_secure ) );
tabsDef.put( "destinationTab", R.id.destinationTab );
tabs.addTab( spec );

spec = tabs.newTabSpec( "freeHuntTab" )
           .setContent( R.id.freeHuntTab )
           .setIndicator( getString( R.string.free_hunting_button ), getResources().getDrawable( R.drawable.ic_my_own ) );
tabsDef.put( "freeHuntTab", R.id.freeHuntTab );
tabs.addTab( spec );

what am I missing?

TIA

injecteer
  • 20,038
  • 4
  • 45
  • 89
  • Yeah, I tried to use my custom textView, but now I need to re-invent the whole tab's structure again, with all children, states etc. Heck, I only want to see my icons using the standard API! – injecteer Sep 14 '13 at 10:21
  • See my answer here: http://stackoverflow.com/a/19541791/554281 , hope it'll help – Andrei Buneyeu Oct 23 '13 at 12:37

1 Answers1

0
TabHost tabHost = getTabHost();

TabSpec photospec = tabHost.newTabSpec("Photos");
photospec.setIndicator("Photos", getResources().getDrawable(R.drawable.photos_gray));
Intent photosIntent = new Intent(this,Photosactivity.class);
photospec.setContent(photosIntent);

This is working... But icons and texts are not parallely shown, any one will be viewable either Text or Icon

ddb
  • 2,423
  • 7
  • 28
  • 38