How can i use tabs to switch between activities? For example i have some tabs, one of them includes google map and i want each tab to have its own activity with its own .xml file. How can i do it?
A:
There is a tutorial on the APress Begining android 2 book that does exactly that.
Create an android project from existing source in eclipse using the folder from the source code "Fancy\Tab"
After you got your tab thing running, just substitue the activities being loaded into the tabs by what you want. ie a MapActivity.
blindstuff
2010-10-26 17:44:17
u mean instead of spec.setContent(R.id.tab1) i shoud write spec.setContent(R.layout.[name]) and FrameLayout in main.xml should be empty? i tried that but got exception
polyakovsky
2010-10-27 08:29:43
A:
iv also tried in this way, but got same exception
TabHost tabs=(TabHost)findViewById(R.id.tabhost);
Intent intent = new Intent().setClass(this, home_scr.class);
TabHost.TabSpec spec = tabs.newTabSpec("tabHome").setIndicator("H").setContent(intent);
tabs.addTab(spec);
polyakovsky
2010-10-27 08:52:08
A:
i've solved the problem. in addition to
TabHost tabs=(TabHost)findViewById(R.id.tabhost);
Intent intent = new Intent().setClass(this, home_scr.class);
TabHost.TabSpec spec = tabs.newTabSpec("tabHome").setIndicator("H").setContent(intent);
tabs.addTab(spec);
value of "android:id" in xml file with discription of TabHost must be "@android:id/tabhost", also FrameLayout must have "android:id="@android:id/tabcontent", but not another names.
polyakovsky
2010-10-29 14:55:00