0

I'm new to Android development.

I've added a TabHost to my Android application, and can change the text of the three tabs I have just fine. I can click them to show different views, etc.

But where and how do I add an icon to a specific tab? Not change it programmatically, but actually add it on layout design? In the XML or using the designer somehow?

Squonk
  • 48,735
  • 19
  • 103
  • 135
Ethan Allen
  • 14,425
  • 24
  • 101
  • 194

1 Answers1

0

Do as below:

    TabHost tabHost=getTabHost();
    TabHost.TabSpec spec;
    TabHost.TabSpec spec=tabHost.newTabSpec("hello").setIndicator("hello",getResources().getDrawable(R.drawable.ic_launcher)).setContent(intent);
    tabHost.addTab(spec);

this is easiest way to to set icon to secific tab.

AkashG
  • 7,868
  • 3
  • 28
  • 43