Android - TabHost - NullPoinException

0

Próbuje napisac prosty program na androida, bazując w większości na tutorialach z netu i stron androida. Chce dodać 2 zakładki w tabhost i dostaje FATAL EXCEPTION.
Jeżeli wykomentujemy 2 wywołania tabHost.addTab(), NPE znika.
BArdzo prosze o pomoc, siedzę nad tym już II dzień, nie mam pojęcia co jest źle;/
LOGI z ECLIPSE:

 11-17 21:40:16.771: D/AndroidRuntime(1423): Shutting down VM
11-17 21:40:16.771: W/dalvikvm(1423): threadid=1: thread exiting with uncaught exception (group=0x40015560)
11-17 21:40:16.781: E/AndroidRuntime(1423): FATAL EXCEPTION: main
11-17 21:40:16.781: E/AndroidRuntime(1423): java.lang.RuntimeException: Unable to start activity ComponentInfo{pbar.swimtrainer/pbar.swimtrainer.SwimTrainerActivity}: java.lang.NullPointerException
11-17 21:40:16.781: E/AndroidRuntime(1423):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
11-17 21:40:16.781: E/AndroidRuntime(1423):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
11-17 21:40:16.781: E/AndroidRuntime(1423):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-17 21:40:16.781: E/AndroidRuntime(1423):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
11-17 21:40:16.781: E/AndroidRuntime(1423):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-17 21:40:16.781: E/AndroidRuntime(1423):     at android.os.Looper.loop(Looper.java:123)
11-17 21:40:16.781: E/AndroidRuntime(1423):     at android.app.ActivityThread.main(ActivityThread.java:3683)
11-17 21:40:16.781: E/AndroidRuntime(1423):     at java.lang.reflect.Method.invokeNative(Native Method)
11-17 21:40:16.781: E/AndroidRuntime(1423):     at java.lang.reflect.Method.invoke(Method.java:507)
11-17 21:40:16.781: E/AndroidRuntime(1423):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-17 21:40:16.781: E/AndroidRuntime(1423):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-17 21:40:16.781: E/AndroidRuntime(1423):     at dalvik.system.NativeStart.main(Native Method)
11-17 21:40:16.781: E/AndroidRuntime(1423): Caused by: java.lang.NullPointerException
11-17 21:40:16.781: E/AndroidRuntime(1423):     at android.widget.TabHost.addTab(TabHost.java:212)
11-17 21:40:16.781: E/AndroidRuntime(1423):     at pbar.swimtrainer.SwimTrainerActivity.onCreate(SwimTrainerActivity.java:32)
11-17 21:40:16.781: E/AndroidRuntime(1423):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-17 21:40:16.781: E/AndroidRuntime(1423):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
11-17 21:40:16.781: E/AndroidRuntime(1423):     ... 11 more

kody:
KLASA GŁÓWNA

 package pbar.swimtrainer;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;

public class SwimTrainerActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost);

        TabSpec firstTabSpec = tabHost.newTabSpec("tid1");
        TabSpec secondTabSpec = tabHost.newTabSpec("tid2");

        firstTabSpec.setIndicator("First Tab Name").setContent(new Intent(this,AddRecord.class));
        secondTabSpec.setIndicator("Second Tab Name").setContent(new Intent(this,Statistics.class));

        tabHost.addTab(firstTabSpec);
        tabHost.addTab(secondTabSpec);

        }
}//class

PIERWSZA ZAKŁADKA

 package pbar.swimtrainer;

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

public class AddRecord extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

/* First Tab Content */
TextView textView = new TextView(this);
textView.setText("First Tab");
setContentView(textView);

}
}

DRUGA ZAKŁADKA

package pbar.swimtrainer;

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

public class Statistics extends Activity {
 /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);

 /* Second Tab Content */
 TextView textView = new TextView(this);
 textView.setText("Second Tab");
 setContentView(textView);

 }
 } 

MAIN.XML

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

    <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:id="@+id/LinearLayout01"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" >

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" >
            </TabWidget>

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" >
            </FrameLayout>
        </LinearLayout>
    </TabHost>

</LinearLayout>

ANDROIDMANIFEST.XML

 <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="pbar.swimtrainer"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="10" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >

        <activity
            android:label="@string/app_name"
            android:name=".SwimTrainerActivity" >
            <intent-filter >
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".AddRecord" 
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar">
        </activity>
        <activity android:name=".Statistics" 
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar">
        </activity>
    </application>

</manifest>
0

SOLVED

powinno być:

 public class SwimTrainerActivity extends TabActivity {

a nie

 public class SwimTrainerActivity extends Activity {

1 użytkowników online, w tym zalogowanych: 0, gości: 1, botów: 0