Android Make default tabs, but without any content.

So, I want to have tabs with the default style, but I want to handle the content myself. If I try to create them only with:

TabSpec tabT = mainTabHost.newTabSpec("tabT").setIndicator("T"); tabHost.add(tabT);

I get an error that the contents are not specified.

Then I tried to add tabs with tabwidget directly, but I don't know how to get the default style for tabs.

Any tips?

+8
android view tabs
source share
2 answers

Try TabContentFactory with an empty view:

 tabSpec.setContent(new EmptyTabFactory()); 

class factory:

 private class EmptyTabFactory implements TabContentFactory { @Override public View createTabContent(String tag) { return new View(mContext); } } 
+18
source share

To set the content, you must use the setContent method:

 TabSpec tabT = mainTabHost.newTabSpec("tabT").setIndicator("T").setContent(viewId); 

Look here for an example.

-one
source share

All Articles