Anyone know what this error mean for android tabs?

旧巷老猫 提交于 2019-12-30 11:12:24

问题


I am trying to try out the tutorial online and wanted to put the tab to the layout xml. I have change the extends from Activity to TabActivity. In the design view of the layout xml, I have the below.

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 following classes could not be found:

I have looked for solution but none of them fixed except I found one in different language. I tried using the translator on google but not so helpful.

Does anyone manage to get the tabs function.

I am using Android 2.2 Api and develop with an eclipse IDE


回答1:


Known bug http://code.google.com/p/android/issues/detail?id=13092

A user suggested to switch build target to 1.6 and the issue goes away. Obviously a temporary fix.




回答2:


You need a layout like this:

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

See the Tab Layout tutorial for more info.




回答3:


Do you have a TabWidget with id android:id/tabs as the error message tells you you need?




回答4:


Switch to android Target 3.0 or 3.1. You can find that drop down list on the top right side




回答5:


I had the same issue. The workaround is detailed in this link:

Comment 63 by blundell...@gmail.com, May 5, 2011

As stated above Quick Fix: Just change the API Target (top left of XML graphical view) to 3.0 and you can see it



来源:https://stackoverflow.com/questions/4963773/anyone-know-what-this-error-mean-for-android-tabs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!