Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's a good practice to have one activity and multiple views for your tabs. However, that does mean you have to be careful to handle which tab is selected, different menus and context menus for each tab view, etc.</p> <blockquote> <p>I guess my question is, is there a GOOD tutorial somewhere showing exactly how to do complex tasks with a TabHost? I've seen HelloTabWidget; I'm looking for something much more sophisticated than this.</p> </blockquote> <p>I wrote a slightly better tutorial on my blog that demonstrates an interacting ListView and MapView as tabs. Here's the link: <a href="http://joshclemm.com/writing/android-tabs-with-interacting-map-and-list-views/" rel="nofollow noreferrer">Android Tabs with interacting map and list views</a></p> <p>The basics is to have a layout similar to the one in the HelloTabWidget tutorial, make your activity extend from MapActivity, extract the tabhost from the XML and make sure you call setup() on the tabhost. After that, adding views as the content of tabs, tab listeners, etc. are the same.</p> <p>Here's a brief starting point for the class:</p> <pre><code>public class TabbedListMapActivity extends MapActivity { private ListView listView; private MapView mapView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); tabHost = (TabHost) findViewById(android.R.id.tabhost); // setup must be called if not a TabActivity tabHost.setup(); // setup list view listView = (ListView) findViewById(R.id.list); // setup map view mapView = (MapView) findViewById(R.id.mapview); // add views to tab host tabHost.addTab(tabHost.newTabSpec("List").setIndicator("List").setContent(new TabContentFactory() { public View createTabContent(String arg0) { return listView; } })); tabHost.addTab(tabHost.newTabSpec("Map").setIndicator("Map").setContent(new TabContentFactory() { public View createTabContent(String arg0) { return mapView; } })); } </code></pre> <p>...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload