2011-09-09 34 views
0

我分配一個ListActivity作爲Tab contnet。一切工作正常,但我無法看到所有列表項目結果。我只在第二項的一半隻有可見的2項,我知道我的列表包含超過100項。 任何猜測?Android:ListView內TabHost

+++++編輯++++

Tab view Layout: 
================ 

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="fill_parent" 
    android:background="@drawable/bg" android:layout_height="fill_parent"> 

    <TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@android:id/tabhost" android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 
     <LinearLayout android:orientation="vertical" 
      android:layout_width="fill_parent" android:layout_height="fill_parent"> 
      <View android:layout_width="fill_parent" android:layout_height="0.5dip" 
       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="2dip" 
       android:background="#000" /> 
      <ScrollView android:id="@+id/ScrollView01" 
       android:layout_width="fill_parent" android:layout_height="fill_parent"> 
       <FrameLayout android:id="@android:id/tabcontent" 
        android:layout_width="fill_parent" android:layout_height="wrap_content"> 

       </FrameLayout> 
      </ScrollView> 
     </LinearLayout> 
    </TabHost> 
</LinearLayout> 


Tab Activity: 
============= 
onCreate(): 

     mTabHost = (android.widget.TabHost) findViewById(android.R.id.tabhost); 
     mTabHost.setup(getLocalActivityManager()); 
     mTabHost.getTabWidget().setDividerDrawable(R.drawable.tab_divider); 

     Intent list1Intent = new Intent(LIST1);  
     View tabview1 = createTabView(mTabHost.getContext(), "Tab1"); 
     mTabHost.addTab(mTabHost.newTabSpec("tab1").setIndicator(tabview1) 
       .setContent(new Intent(list1Intent))); 

     View tabview2 = createTabView(mTabHost.getContext(), "Tab2"); 
     mTabHost.addTab(mTabHost.newTabSpec("tab2").setIndicator(tabview2) 
       .setContent(commentsIntent));        
     mTabHost.setCurrentTab(0);  


LIST1 layout: 
============= 
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" android:layout_height="fill_parent" 
    android:background="@drawable/bg" android:orientation="vertical" 
    android:id="@+id/rootView"> 

    <TextView android:layout_width="wrap_content" 
     android:layout_height="wrap_content" android:id="@+id/cs_list_empty" 
     android:text="No Data"></TextView> 

    <ListView android:id="@+id/android:list" android:layout_width="fill_parent" 
     android:layout_height="fill_parent" android:cacheColorHint="#00000000" 
     android:divider="#E6E8E9" android:dividerHeight="2dip" 
     android:clickable="false" android:choiceMode="none" android:focusable="false" /> 

</LinearLayout> 

感謝, Venkat Papana

+0

當你在列表主機之外放置listview時,你能看到所有項目嗎? – blessenm

+0

是@blessenm,它在tabhost之外工作正常。 –

+0

如果你在日誌貓有任何錯誤把它放。或者把你的代碼放好。 – blessenm

回答

1

,因爲它已經實現了滾動,滾動視圖將interupt的優化技術,您不應該ListActivity使用滾動視圖爲列表活動做準備。

充分利用tabcontent的FrameLayout作爲

<FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" 
    android:layout_height="0dip" android:layout_weight="1.0"/> 

這將使FrameLayout裏充滿整個剩餘空間。

+0

謝謝,它爲我的列表視圖工作,但我有滾動問題,如果我的選項卡之一包含多個視圖的長線性佈局..(不列表視圖)。你可以請建議我如何解決此問題..謝謝 –

+0

嗨@blesenm,忽略我以前的評論。我通過在scrollview中放置linearlayout來固定線性佈局滾動。像:<! - TAB1(未列表視圖) - > \t \t \t <的LinearLayout> \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t <的LinearLayout> \t \t \t \t \t \t \t \t <! - TAB2(列表視圖) - > \t \t \t \t <的LinearLayout> \t \t \t \t \t \t' –