【问题标题】:TabHost NullPointerException in layout布局中的 TabHost NullPointerException
【发布时间】:2010-04-26 13:28:29
【问题描述】:

我一直在关注 Google 提供的 Tab 示例。我正在尝试使用提供的 XML 布局来设置选项卡布局。

我使用这个 XML 布局@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>

当我在 Eclipse 布局设计器中切换“布局”选项卡时,我的 Eclipse 中会出现 NullPointerException: null 错误。

当我尝试将 TabHost 和 TabWidget 拖放到空的布局文件中时,也会发生这种情况。

我做错了什么?这看起来很简单。

【问题讨论】:

  • 示例代码的所有问题都列在here.

标签: android eclipse


【解决方案1】:

发现它已被记录为问题

http://code.google.com/p/android/issues/detail?id=2021

还是谢谢

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多