I want to create tabs which will show certain views I create through code. Now I can pass a View to TabHost, but only by id.
So I tried to assign some random id, say 1001 to my programmatically created view –
TabHost th = getTabHost();
View v=getMyView(); v.setId(1001);
th.addTab(th.newTabSpec("tab1").setIndicator("Monthly").setContent(v.getId()));
I get a Forced Close when I run this with the message that there is no view number 1001.
Is there any other way I can use my own generated views in TabHost, or a tabbed interface?
You need to use the version of the overloaded
setContent()method that takes a TabHost.TabContentFactory.