Reputation: 1381
I'm trying to add icon in my tabspec in FragmentActivity . but when I add it . just text appear . but if I left the text blank . the icon will be appear . what should I do ?
public class FragmentTabs extends FragmentActivity {
private FragmentTabHost mTabHost;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
Resources r = getResources();
for (int i = 0; i < 3; i++) {
TabSpec t = mTabHost.newTabSpec("simple " + i).setIndicator("a",
r.getDrawable(R.drawable.ic_launcher));
mTabHost.addTab(t, SimpleFrag.class, null);
}
}
}
Upvotes: 1
Views: 57
Reputation: 13807
The behaviour of the TabHost depends on the device and Android version, by default on some combinations of device/SDK version the TabHost will not display the tab icon if text is present. See this this answer for more detail and a proposed solution.
Upvotes: 1