TabHost NullPointerException in layout

Posted by Chubbs on Stack Overflow See other posts from Stack Overflow or by Chubbs
Published on 2010-04-26T13:28:29Z Indexed on 2010/05/19 20:50 UTC
Read the original article Hit count: 537

Filed under:
|

I been following the Tab example provided by Google. I am trying to use the XML layout provided to setup a tab layout.

I use this XML layout @ http://developer.android.com/guide/tutorials/views/hello-tabwidget.html

<?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">
        <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="this is a tab" />
            <TextView 
                android:id="@+id/textview2"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" 
                android:text="this is another tab" />
            <TextView 
                android:id="@+id/textview3"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" 
                android:text="this is a third tab" />
        </FrameLayout>
    </LinearLayout>
</TabHost>

When ever I switch the Layout tab in the Eclipse layout designer I get a NullPointerException: null error inside my Eclipse.

This happens also when I try to drag and drop a TabHost, and then a TabWidget into an empty layout file.

What am I doing wrong ? this seems pretty simple.

© Stack Overflow or respective owner

Related posts about android

Related posts about eclipse