0

I am trying to create template/BaseActivity class for other developers to use, as a part of framework.

I extended my class with TabActivity, and my xml looks like this/

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

when I use this activity by extending in other project, I get an error stating, it is not able to get android.R.id.tabhost and this is necessary.

This happens, even if i call getTabHost() or findViewById() both scenarios.

Please note : I tried this without extending the TabActivity, for the use of views in tab. It works fine. But I want to use activities as my tab content.

I think this is the issue when we make it a library project and include it.

Please let me know if you need more explanation or if you know some workarounds, please suggest.

Programmer Bruce
  • 64,977
  • 7
  • 99
  • 97
Ganesh Bhat
  • 243
  • 2
  • 10

1 Answers1

2

I got around with the issue. Provided a library class which requires user to pass the current activity instance to my templateLibrary.

It calls sets the Conetnt as one of the layout file containing android tab. Then get the tab host.

Let me know if anyone wants more details on this. If you are developing a framework providing layout to user.

Ganesh Bhat
  • 243
  • 2
  • 10