开发者

Android TabHost inside LinearLayout

Hey... i'm trying to create an activity with the layout structure like this:

<?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"
        >
        <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
            <TabWidget android:layout_width="fill_parent"
                android:layout_height="wrap_content" 
                android:id="@android:id/tabs" 
           开发者_StackOverflow     /> 
            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                >
            </FrameLayout>
        </LinearLayout>
     </TabHost>

     <some code here>

</LinearLayout>

What is wrong here? I'm getting nullPointerException in my activity

public class TabsActivity extends Activity
{
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tabs);

        // Resources res = getResources();
        // TabHost tabHost = (TabHost)findViewById(R.id.tabHost);
   }
}

The problem is with nesting. There is no problem with the TabHost as the main XML node. Thx!

Error:

Android TabHost inside LinearLayout


You are misinterpreting your stack trace.

The exception is occurring inside Intent. The Intent you are using to start the activity is invalid. Fix your Intent, and your problem will go away.


I had a similar problem and the solution was to get the TabHost and call setup(). Hard to say if that's your problem here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜