2011-05-04 42 views
1

我在TabHost中有一个FrameLayout。我收到以下错误。我怎样才能让它在Eclipse中呈现?在PostHost过程中出现TabHost错误

Error during post inflation process: 
The FrameLayout for the TabHost has no content. Rendering failed. 

这里是我的XML

<?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"> 

    <!-- 
    <RelativeLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/actionbarRelativeLayout"> 
     <ImageButton android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="@drawable/icon" android:id="@+id/stocktwitsImageButton"></ImageButton> 
     <ImageButton android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="@drawable/icon" android:id="@+id/composeImageButton" android:layout_alignParentRight="true"></ImageButton> 
    </RelativeLayout> 
--> 

    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:padding="5dp"> 
     <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:padding="5dp" /> 
    </LinearLayout> 
</TabHost> 

回答

1

这是摘自Android的源setupTabHost方法:

final int count = content.getChildCount(); 

if (count == 0) { 
    throw new PostInflateException(
      "The FrameLayout for the TabHost has no content. Rendering failed.\n"); 
} 

作为例外说,你需要有内容。重构XML到:

<FrameLayout android:id="@android:id/tabcontent" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:padding="5dp"> 
    <LinearLayout android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:id="@+id/tab1"></LinearLayout> 
</FrameLayout> 
+0

是的,你说得对,这是什么导致错误信息。然而,我(可能还有其他人)在运行期间填写了这个信息;它添加了更多的代码,因为我必须删除此选项卡。我想这是进步。叹。 – 2012-08-22 13:41:09

+0

好的,ghost选项卡不显示(图形布局编辑器除外)!酷 - 猜我应该等待,直到我在抱怨前先测试它。 – 2012-08-22 13:51:09