Tabhost教程坏了?
我一直在尝试在 SDK 中完成 TabHost 教程,但由于某种原因,它似乎中断了。在第 4 步中,我复制并粘贴 xml 代码,但出现错误,导致其无法正常膨胀。错误是:
Error in an XML file: aborting build.
这是在 xml 文件的图形布局中。
Error during post inflation process:
TabHost requires a TabWidget with id "android:id/tabs",
View found with id "tabs" is 'com.android.layoutlib.bridge.MockView'
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">
<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>
我做错了什么吗?
Possible Duplicate:
Anyone know what this error mean for android tabs?
I have been trying to do the TabHost tutorial in the SDK but for some reason, is appears to break. On Step 4 I copy and paste the xml code, I get an error that prevents it from inflating properly. the error is:
Error in an XML file: aborting build.
This is in the graphical layout of the xml file.
Error during post inflation process:
TabHost requires a TabWidget with id "android:id/tabs",
View found with id "tabs" is 'com.android.layoutlib.bridge.MockView'
The xml file Itself has this in it.
<?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"
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>
Am I doing something wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用这个模板:
Use this template:
请参阅第 5 步,您的 Activity 必须扩展 TabActivity,而不是 Activity
See step 5 , your Activity must extend TabActivity, not Activity
在图形布局本身中切换到 android target 3.0 或 3.1。您可以在右上角找到下拉列表
Switch to android target 3.0 or 3.1 in the graphical layout itself. You can find the drop down list on the top right corner
您可以使用此处找到的更新的渲染库:Android Tools。
只需将
\layoutlib\[platform version]
中找到的目录提取到\[sdk dir]\platforms\[platform version]
并让它覆盖layoutlib< /代码>。
You can use the updated rendering library found here: Android Tools.
Just extract the directories found in
\layoutlib\[platform version]
to\[sdk dir]\platforms\[platform version]
and let it override thelayoutlib
.