2011-02-07 29 views
0

我正在尝试为其他开发人员创建模板/ BaseActivity类,以作为框架的一部分使用。库项目中的TabActivity,未找到android.R.id.tabhost错误

我伸出我的类TabActivity,和我的XML看起来像这样/

<TabHost 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="fill_parent" android:layout_height="fill_parent"> 
     <View android:layout_width="fill_parent" android:layout_height="0dip" 
      android:background="#000" /> 
     <TabWidget android:id="@android:id/tabs" 
      android:layout_width="fill_parent" android:layout_height="wrap_content" 
      android:layout_marginLeft="0dip" android:layout_marginRight="0dip" /> 
     <View android:layout_width="fill_parent" android:layout_height="2dip" 
      android:background="#696969" /> 
     <View android:layout_width="fill_parent" android:layout_height="1dip" 
      android:background="#fff" /> 
     <FrameLayout android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent" android:layout_height="fill_parent" /> 
    </LinearLayout> 
</TabHost> 

,当我在其他项目中扩大使用此活动,我得到一个错误,说明,它没有能够得到机器人。 R.id.tabhost,这是必要的。

发生这种情况,即使我调用getTabHost()或findViewById()这两种情况。

请注意:我试过这个没有扩展TabActivity,在tab中使用视图。它工作正常。但我想使用活动作为我的标签内容。

我认为这是我们制作图书馆项目并将其纳入的问题。

请让我知道如果您需要更多的解释或如果你知道一些解决方法,请建议。

回答

2

我解决了这个问题。 提供了一个库类,它需要用户将当前活动实例传递给我的templateLibrary。

它调用将Conetnt设置为包含android选项卡的布局文件之一。 然后获取标签主机。

让我知道是否有人想了解更多细节。 如果您正在开发为用户提供布局的框架。

+0

我面临着同样的问题,我希望看到更多的细节或者你如何解决它的代码示例。 – Hermit 2012-04-11 12:45:55

相关问题