Android: How do you set up the TabHost
<p>I am trying to use the tabhost when I add it to my xml it doesn't look right, and I believe there is something that needs to be done in java, I am trying to set up three tabs with three different classes is this possible?</p>

<p>Here is my xml:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" &gt;

    &lt;LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" &gt;

        &lt;TabHost
            android:id="@android:id/tabhost"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1" &gt;

            &lt;LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical" &gt;

                &lt;TabWidget
                    android:id="@android:id/tabs"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" &gt;
                &lt;/TabWidget&gt;

                &lt;FrameLayout
                    android:id="@android:id/tabcontent"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" &gt;

                    &lt;LinearLayout
                        android:id="@+id/tab1"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent" &gt;

                        &lt;TextView
                            android:id="@+id/textView1"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Browser History:"
                            android:textAppearance="?android:attr/textAppearanceLarge" /&gt;

                        &lt;TextView
                            android:id="@+id/hello"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" /&gt;
                    &lt;/LinearLayout&gt;

                    &lt;LinearLayout
                        android:id="@+id/tab2"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent" &gt;

                        &lt;TextView
                            android:id="@+id/textView2"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Call Log"
                            android:textAppearance="?android:attr/textAppearanceLarge" /&gt;

                        &lt;TextView
                            android:id="@+id/call"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" /&gt;
                    &lt;/LinearLayout&gt;

                    &lt;LinearLayout
                        android:id="@+id/tab3"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent" &gt;

                        &lt;TextView
                            android:id="@+id/textView3"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Text Messages"
                            android:textAppearance="?android:attr/textAppearanceLarge" /&gt;

                        &lt;TextView
                            android:id="@+id/tvSms"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" /&gt;
                    &lt;/LinearLayout&gt;
                &lt;/FrameLayout&gt;
            &lt;/LinearLayout&gt;
        &lt;/TabHost&gt;
    &lt;/LinearLayout&gt;

&lt;/LinearLayout&gt; 
</code></pre>

<p>And I have three different classes, because I am trying to use each tab to open each activity. </p>

<p>Here are the Classes </p>

<pre><code>  package com.johnnydicamillo.spybeta;

import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.Browser;
import android.widget.TabHost;
import android.widget.TextView;

public class AndroidSpybetaActivity extends TabActivity {
    /** Called when the activity is first created. */
    Resources res;
    TabHost tabHost;
    Intent intent;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        res = getResources();
        tabHost = getTabHost();
        TabHost.TabSpec spec;

        intent = new Intent().setClass(this, Messaging.class);
        spec = tabHost.newTabSpec("messaging").setIndicator("Messaging")
                .setContent(intent);
        tabHost.addTab(spec);

        intent = new Intent().setClass(this, TestingData.class);
        spec = tabHost.newTabSpec("Calls").setIndicator("Calls")
                .setContent(intent);
        tabHost.addTab(spec);
        tabHost.setCurrentTab(0);

        TextView view = (TextView) findViewById(R.id.hello);
        Cursor mCur = managedQuery(android.provider.Browser.BOOKMARKS_URI,
                null, null, null, null);
        mCur.moveToFirst();
        int index = mCur.getColumnIndex(Browser.BookmarkColumns.TITLE);
        while (mCur.isAfterLast() == false) {
            view.append(" WebSite " + mCur.getString(index));
            mCur.moveToNext();
        }
    }
}
</code></pre>

<p>Second </p>

<pre><code>package com.johnnydicamillo.spybeta;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class Messaging extends TabActivity{
    static TextView messageBox;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        messageBox = (TextView) findViewById(R.id.tvSms);

    }
    public static void updateMessageBox(String msg) {
        messageBox.append(msg);
    }

}
</code></pre>

<p>and third</p>

<pre><code>package com.johnnydicamillo.spybeta;

import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.CallLog;
import android.provider.CallLog.Calls;
import android.widget.TextView;

public class TestingData extends TabActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        TextView view = (TextView) findViewById(R.id.call);
        String[] projection = new String[] {

        Calls.NUMBER

        };
        Cursor mCur = managedQuery(CallLog.Calls.CONTENT_URI, projection,
                Calls.DURATION + "&lt;?", new String[] { "60" }, Calls.DURATION
                        + " ASC");
        mCur.moveToFirst();

        while (mCur.isAfterLast() == false) {
            for (int i = 0; i &lt; mCur.getColumnCount(); i++) {
                view.append(" Number " + mCur.getString(i));
            }
            mCur.moveToNext();
        }
    }
}
</code></pre>

<p>Here is my logcat:</p>

<pre><code>08-12 15:19:16.368: D/AndroidRuntime(280): Shutting down VM
08-12 15:19:16.368: W/dalvikvm(280): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
08-12 15:19:16.628: E/AndroidRuntime(280): FATAL EXCEPTION: main
08-12 15:19:16.628: E/AndroidRuntime(280): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.johnnydicamillo.spybeta/com.johnnydicamillo.spybeta.AndroidSpybetaActivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.johnnydicamillo.spybeta/com.johnnydicamillo.spybeta.Messaging}; have you declared this activity in your AndroidManifest.xml?
08-12 15:19:16.628: E/AndroidRuntime(280):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
08-12 15:19:16.628: E/AndroidRuntime(280):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
08-12 15:19:16.628: E/AndroidRuntime(280):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
08-12 15:19:16.628: E/AndroidRuntime(280):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
08-12 15:19:16.628: E/AndroidRuntime(280):  at android.os.Handler.dispatchMessage(Handler.java:99)
08-12 15:19:16.628: E/AndroidRuntime(280):  at android.os.Looper.loop(Looper.java:123)
08-12 15:19:16.628: E/AndroidRuntime(280):  at android.app.ActivityThread.main(ActivityThread.java:4627)
08-12 15:19:16.628: E/AndroidRuntime(280):  at java.lang.reflect.Method.invokeNative(Native Method)
08-12 15:19:16.628: E/AndroidRuntime(280):  at java.lang.reflect.Method.invoke(Method.java:521)
08-12 15:19:16.628: E/AndroidRuntime(280):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-12 15:19:16.628: E/AndroidRuntime(280):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-12 15:19:16.628: E/AndroidRuntime(280):  at dalvik.system.NativeStart.main(Native Method)
08-12 15:19:16.628: E/AndroidRuntime(280): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.johnnydicamillo.spybeta/com.johnnydicamillo.spybeta.Messaging}; have you declared this activity in your AndroidManifest.xml?
08-12 15:19:16.628: E/AndroidRuntime(280):  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
08-12 15:19:16.628: E/AndroidRuntime(280):  at android.app.ActivityThread.resolveActivityInfo(ActivityThread.java:2473)
08-12 15:19:16.628: E/AndroidRuntime(280):  at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:277)
08-12 15:19:16.628: E/AndroidRuntime(280):  at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:651)
08-12 15:19:16.628: E/AndroidRuntime(280):  at android.widget.TabHost.setCurrentTab(TabHost.java:323)
08-12 15:19:16.628: E/AndroidRuntime(280):  at android.widget.TabHost.addTab(TabHost.java:213)
08-12 15:19:16.628: E/AndroidRuntime(280):  at com.johnnydicamillo.spybeta.AndroidSpybetaActivity.onCreate(AndroidSpybetaActivity.java:31)
08-12 15:19:16.628: E/AndroidRuntime(280):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-12 15:19:16.628: E/AndroidRuntime(280):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
08-12 15:19:16.628: E/AndroidRuntime(280):  ... 11 more
08-12 15:19:21.929: I/Process(280): Sending signal. PID: 280 SIG: 9
</code></pre>
