dtngn wrote:
> Hi all,
> 
> Can anyone help me to solve this problem with TabHost.
> 
> I am now using TabHost to create a tabbed view. The SDK document
> suggest that I must call setup() function before adding tabs to the
> TabHost widget. But when I run the application on the Emulator, the
> setup() function throw a RuntimeException than contain the following
> message:
> 
>         Your TabHost must have a TabWidget whose id attribute is
> 'android.R.id.tabs'
> 
> Can anyone explain me why this exception is thrown and how to get rid
> of it.

By putting a TabWidget in your layout with an android:id="@android:id/tabs".

For example:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android";
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <TabHost android:id="@+id/tabhost"
                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"
                        android:paddingTop="62px">
                        <AnalogClock android:id="@+id/tab1"
                                android:layout_width="fill_parent"
                                android:layout_height="fill_parent"
                                android:layout_centerHorizontal="true"
                        />
                        <Button android:id="@+id/tab2"
                                android:layout_width="fill_parent"
                                android:layout_height="fill_parent"
                                android:text="A semi-random button"
                        />
                </FrameLayout>
        </TabHost>
</LinearLayout>

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com

Android Training on the Ranch! -- Mar 16-20, 2009
http://www.bignerdranch.com/schedule.shtml

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to