2011-02-07 7 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를 확장하지 않고이 기능을 사용했습니다. 그것은 잘 작동합니다. 하지만 탭 콘텐트로 액티비티를 사용하고 싶습니다.

우리가 도서관 프로젝트로 만들고 포함시킬 때 이것이 문제라고 생각합니다.

자세한 설명이 필요하거나 해결 방법을 알고있는 경우 알려 주시기 바랍니다.

답변

2

나는이 문제를 해결했다. 사용자가 현재 활동 인스턴스를 내 templateLibrary로 전달해야하는 라이브러리 클래스가 제공됩니다.

이 호출은 Conetnt를 Android 탭이있는 레이아웃 파일 중 하나로 설정합니다. 그런 다음 탭 호스트를 가져옵니다.

자세한 내용을 알고 싶다면 알려주세요. 사용자에게 레이아웃을 제공하는 프레임 워크를 개발중인 경우.

+0

나는 동일한 문제에 직면하고 있습니다. 자세한 내용이나 해결 방법에 대한 코드 예를보고 싶습니다. – Hermit