A: 

See the Hello Tab Layout tutorial for details, but basically it expects a LinearLayout under TabHost with a TabWidget and a FrameLayout. Your contents would go under the FrameLayout:

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="5dp">
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="5dp" />
    </LinearLayout>
</TabHost>
Mayra
A: 

I changed my code to the following and it worked perfectly. Thanks Mayra!

<LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />
    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <TextView 
            android:id="@+id/textview1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" 
            android:text="" />
        <TextView 
            android:id="@+id/textview2"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" 
            android:text="" />
        <TextView 
            android:id="@+id/textview3"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" 
            android:text="" />
        <TextView 
            android:id="@+id/textview4"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" 
            android:text="" />
                <ListView 

android:id="@+id/lstMain" android:layout_width="wrap_content" android:layout_height="wrap_content">

   </TabHost>
A: 

Hello, Thanks for this post. It was very helpful for me to understand some architecture related to Android. I was wondering if someone could look into my code and also tell me where I am going wrong. My problem is very similar to this issue, in short i need to have list view inside a tab. Somehow with the existing code the application is crashing. Any help please.

Here is the code for my HelloAndroid Java file

package com.example.helloandroid;

import java.util.ArrayList; import java.util.Arrays;

import android.app.TabActivity; import android.os.Bundle; import android.view.Window; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TabHost;

public class HelloAndroid extends TabActivity { /** Called when the activity is first created. */ private ListView mainListView ;
private ArrayAdapter listAdapter ; @Override

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.main);

    TabHost mTabHost = getTabHost();

    mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator("TAB 1"));
    mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("TAB 2"));
    mTabHost.addTab(mTabHost.newTabSpec("tab_test3").setIndicator("TAB 3"));

    mTabHost.setCurrentTab(0);

 // Find the ListView resource.   
    mainListView = (ListView) findViewById( R.id.lstMain);  

    // Create and populate a List of planet names.  
    String[] planets = new String[] { "Mercury", "Venus", "Earth", "Mars",  
                                      "Jupiter", "Saturn", "Uranus", "Neptune"};    
    ArrayList<String> planetList = new ArrayList<String>();  
    planetList.addAll( Arrays.asList(planets) );  

    // Create ArrayAdapter using the planet list.  
   listAdapter = new ArrayAdapter<String>(this, R.layout.main, planetList);  

    // Set the ArrayAdapter as the ListView's adapter.  
    mainListView.setAdapter( listAdapter ); 


 // End


}

}

and here is the code for my xml file.