2012-08-09 69 views
0

我有一些動態列表,它增長了一些輸入,我也有選項卡和它上面的一些佈局。我想滾動它們以及列表增長。 只是簡單的話不加載完整列表,但滾動其他東西,因爲我滾動列表。 我正在做這樣的事情。如何將ListView與一些其他視圖放入ScrollView中而不會摺疊?

<ScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <TabHost 
     android:id="@android:id/tabhost" 
     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" 
       android:layout_weight="0" 
       android:dividerPadding="5dp" 
       android:orientation="horizontal" /> 

      <FrameLayout 
       android:id="@android:id/tabcontent" 
       android:layout_width="0dp" 
       android:layout_height="0dp" 
       android:layout_weight="0" /> 

      <FrameLayout 
       android:id="@+android:id/realtabcontent" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" /> 
     </LinearLayout> 
    </TabHost> 
</ScrollView> 

note 我也想滾動製表符。 I M目前正在使用此代碼

public static class Utility { 
    public static void setListViewHeightBasedOnChildren(ListView listView) { 
     ListAdapter listAdapter = listView.getAdapter(); 
     if (listAdapter == null) { 
      // pre-condition 
      return; 
     } 

     int totalHeight = 0; 
     for (int i = 0; i < listAdapter.getCount(); i++) { 
      View listItem = listAdapter.getView(i, null, listView); 
      listItem.measure(0, 0); 
      totalHeight += listItem.getMeasuredHeight(); 
     } 

     ViewGroup.LayoutParams params = listView.getLayoutParams(); 
     params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); 
     listView.setLayoutParams(params); 
    } 
} 

用於製作列表視圖,但是,當我加載畫面從列表中未從標籤focuse屏幕。任何人都知道如何開始從頂部開始聚焦 請幫助

+0

添加到scroolVIew機器人:fillViewport =「真」 – 2012-08-09 10:45:24

+0

我沒有幫助。當我滾動我的列表只是滾動在小窗口中沒有標籤或其他動作來看,以有地方 – 2012-08-09 10:52:03

回答

0

您的ListView將始終獨立於其他列表進行滾動。如果你想讓所有東西都一起滾動,那麼你需要看看使用LinearLayout來模仿ListView並將每一行添加到佈局。這將強制佈局遵守外部滾動視圖容器。

+0

但在我condision這是不可能becouse即時通訊列表樹視圖 – 2012-08-10 02:58:33

相關問題