【发布时间】:2012-12-31 12:00:07
【问题描述】:
简单的 android.support.v4.app.FragmentTabHost 的图形布局永远不会在 Eclipse 或 Android Studio 中呈现。
我得到的控制台错误始终是:Exception raised during rendering: No tab known for tag null
我使用的是最基本的 XML 文件:
<android.support.v4.app.FragmentTabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TabWidget
android:id="@android:id/tabs"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0"/>
<FrameLayout
android:id="@+id/realtabcontent"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
</LinearLayout>
</android.support.v4.app.FragmentTabHost>
但同样的错误发生了。
我只是想在选项卡小部件和框架布局的上方或下方添加更多视图。
我不太关心看到标签内容;我只想查看 我的布局的其余部分 - 但问题是当一个 android.support.v4.app.FragmentTabHost 驻留在布局中时不会呈现其他视图。
我已阅读并尝试通过此帖子的答案解决问题:
Android: Tabs at the bottom with FragmentTabHost
但我不认为那是我的问题;我不想在底部放置 TabWidget。
我的每个其他 XML 文件都可以完美打开。
同样的问题出现在Android Studio中:
【问题讨论】:
-
那个错误是 logcat 还是控制台?如果是logcat,请发帖。
-
这是一个错误日志:在 Eclipse 中:(渲染期间引发的异常:No tab known for tag null 异常详细信息记录在 Window > Show View > Error Log 中)
-
FragmentTabHost 不会显示任何内容,因为内容是动态添加的。所以他们没有问题。当您在代码中添加选项卡并对其进行测试时,应该可以工作。 androidhive.info/2011/08/android-tab-layout-tutorial
-
我打开了一个错误报告,请投票:code.google.com/p/android/issues/detail?id=78772
标签: android android-layout android-studio android-support-library