Android Eclipse将tabhost添加到项目错误

Android Eclipse将tabhost添加到项目错误,android,eclipse,android-tabhost,Android,Eclipse,Android Tabhost,当我尝试使用添加TabHost时 RightClick > New > Android XML > Select Root Element :TabHost 它显示tabhost需要一个tabwidget和框架布局 实际上,tabhost是根。我以前如何拥有选项卡控件和框架布局 这是eclipse的错误还是我的错误?正如您在eclipse 3.7.1中所描述的那样,我能够使用根TabHost创建布局,没有任何错误。我相信,作为一种解决方法,您可以使用LinearLayout作

当我尝试使用添加TabHost时

RightClick > New > Android XML > Select Root Element :TabHost
它显示tabhost需要一个tabwidget和框架布局

实际上,tabhost是根。我以前如何拥有选项卡控件框架布局


这是eclipse的错误还是我的错误?

正如您在eclipse 3.7.1中所描述的那样,我能够使用根TabHost创建布局,没有任何错误。我相信,作为一种解决方法,您可以使用LinearLayout作为根创建布局,然后将TabHost放入其中,或者使用TabHost切换LinearLayout

编辑:

<?xml version="1.0" encoding="utf-8"?>
<TabHost
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical"
   android:layout_width="match_parent"
   android:layout_height="match_parent">
   <TabWidget
      android:id="@android:id/tabs"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content">
   </TabWidget>
   <FrameLayout
      android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent"
      android:layout_height="wrap_content">
   </FrameLayout>  
</TabHost>

正如您在eclipse 3.7.1中所描述的那样,我能够使用根TabHost创建布局,没有任何错误。我相信,作为一种解决方法,您可以使用LinearLayout作为根创建布局,然后将TabHost放入其中,或者使用TabHost切换LinearLayout

编辑:

<?xml version="1.0" encoding="utf-8"?>
<TabHost
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical"
   android:layout_width="match_parent"
   android:layout_height="match_parent">
   <TabWidget
      android:id="@android:id/tabs"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content">
   </TabWidget>
   <FrameLayout
      android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent"
      android:layout_height="wrap_content">
   </FrameLayout>  
</TabHost>


在使用Eclipse 3.7.1安装ADK 2.3.3 update 2后,此功能应按您所述工作。

在使用Eclipse 3.7.1安装ADK 2.3.3 update 2后,此功能应按您所述工作。

我已尝试将LinearLayout更改为tabhost,它再次显示如下::tabhost需要id为“android:id/tabs”的TabWidget. 异常详细信息记录在窗口>显示视图>错误日志::中,但在linearlayout下添加tabHost可以正常工作。谢谢你的工作。您是否尝试过将TabWidget和FrameLayout直接添加到xml文件中?没有。当我在linearlayout下添加tabhost时,它们都会自动添加。您需要将tabhost的id放入上述布局中android:id=“@android:id/tabhost”切换布局也不起作用,但当我使用tabhost从xml键入或粘贴整个内容时,它起作用了。我尝试将LinearLayout更改为tabhost,它再次显示如下::tabhost需要一个id为“android:id/tabs”的TabWidget。异常详细信息记录在窗口>显示视图>错误日志::中,但在linearlayout下添加tabHost可以正常工作。谢谢你的工作。您是否尝试过将TabWidget和FrameLayout直接添加到xml文件中?没有。当我在linearlayout下添加tabhost时,它们都会自动添加。您需要将tabhost的id放入上述布局中。android:id=“@android:id/tabhost”切换我的布局也不起作用,但当我使用tabhost从xml键入或粘贴整个内容时,它会起作用。。