Reputation: 546
I am trying to add content in tab view using "setContent(...)" method
TabHost.TabSpec spec = tabs.newTabSpec("tag1");
spec.setContent(R.id.radioGroup1);
spec.setContent(R.id.button1);
when i add more than one item in setContent(...) using different methods it only prefers the last one. How can i add two view under a single tab, in this case- radioGroup1 as well as button1 ?
Thanks
Upvotes: 1
Views: 158
Reputation: 30934
You have to group the two views into a single one - for example a LinearLayout
.
It is typical in Android, that when you do stuff in a callback from the system (like e.g. onCreate
or onButtonPressed
) that the effect only come active after the user code returns and that the last setting 'overrides' previous ones in the same callback, as you have seen.
Upvotes: 1
Reputation: 993
you can not directly add more then one view but aleternative is you can add container view (e.g. linear layout) and inside container layout you can add as many views you want for sure
this is exactly what you want..nice example of tab
Upvotes: 2