2014-12-19 4 views
0

탭 호스트가 있고 세 개의 탭 모두에 동일한 레이아웃 파일을 사용하고 싶습니다. 그러나이 작업을 시도 할 때 탭 중 하나에있는 레이아웃 만 3 가지가 모두 표시되는 것은 아닙니다. 내 탭 호스트 XML 활동TabHost에 동일한 xml 레이아웃 파일 사용

myTabHost =(TabHost) findViewById(R.id.TabHost01); 
    myTabHost.setup(); 

    TabHost.TabSpec spec1 = myTabHost.newTabSpec("First Tab"); 
    spec1.setIndicator("First Tab", getResources().getDrawable(android.R.drawable.ic_menu_add)); 
    spec1.setContent(R.id.tab1); 
    myTabHost.addTab(spec1); 

myTabHost.addTab(myTabHost.newTabSpec("Tab Two"). 
      setIndicator("Tab Two", getResources().getDrawable(android.R.drawable.ic_menu_edit)).setContent(R.id.tab1)); 

그리고 나는

<TabHost 
    android:id="@+id/TabHost01" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical"> 
     <TabWidget 
      android:id="@android:id/tabs" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"> 

      </TabWidget> 
     <!-- container of tabs --> 
     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"> 

      <include 
       android:id="@+id/tab1" 
       android:layout_width="fill_parent" 
       android:layout_height="match_parent" 
       layout="@layout/item_list_view"> 

그러나 탭 두에 나는 item_list_view이 표시되지 않는

있나요?

두 탭에 모두 동일한 XML을 사용할 수 있습니까? 도움을

덕분에

답변

0
myTabHost =(TabHost) findViewById(R.id.TabHost01); 

myTabHost.setup(); 

TabHost.TabSpec spec1 = myTabHost.newTabSpec("First Tab"); 
spec1.setIndicator("First Tab", getResources().getDrawable(android.R.drawable.ic_menu_add)); 
spec1.setContent(R.id.tab1); 
myTabHost.addTab(spec1); 

당신은 porogramatically 바로 콘텐츠를 Tabhpost 내용 공장을 사용하고 있습니다

관련 문제