1

私はLinearLayout垂直方向で使用しており、そのレイアウト内には 4 がありListViewます。このレイアウトは の中に配置しScrollViewました。

私の問題はScrollView、スクロールしていないことです。そのため、すべてのリスト ビューを表示できません。

私がやっていることは次のとおりです。

<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView1"
android:layout_width="wrap_content"
android:layout_height="600dp"
android:fillViewport="true" >




             <LinearLayout
                 android:id="@+id/frag_capt2"
                 android:layout_width="800dp"
                 android:layout_height="match_parent"
                 android:layout_marginLeft="100dp"
                 android:layout_marginTop="20dp"
                 android:orientation="vertical" >

                 <TextView
                     android:id="@+id/linearlayoutteamtv1"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:text="Medium Text"
                     android:textAppearance="?android:attr/textAppearanceMedium"
                     android:textColor="#000000" />


                 <ListView
                     android:id="@+id/ListView01team"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
                     android:layout_marginTop="10dp"
                     android:background="@drawable/pm_cool_listproject_background" >

                 </ListView>



                 <TextView
                     android:id="@+id/linearlayoutteamtv2"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:layout_marginTop="10dp"
                     android:text="Medium Text"
                     android:textAppearance="?android:attr/textAppearanceMedium"
                     android:textColor="#000000" />



                 <ListView
                     android:id="@+id/ListView02team"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
                     android:layout_marginTop="10dp"
                     android:background="@drawable/pm_cool_listproject_background" >

                 </ListView>

                  <TextView
                     android:id="@+id/linearlayoutteamtv3"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:layout_marginTop="10dp"
                     android:text="Medium Text"
                     android:textAppearance="?android:attr/textAppearanceMedium"
                     android:textColor="#000000" />



                 <ListView
                     android:id="@+id/ListView03team"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
                     android:layout_marginTop="10dp"
                     android:background="@drawable/pm_cool_listproject_background" >

                 </ListView>



                  <TextView
                     android:id="@+id/linearlayoutteamtv4"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:layout_marginTop="10dp"
                     android:text="Medium Text"
                     android:textAppearance="?android:attr/textAppearanceMedium"
                     android:textColor="#000000" />



                 <ListView
                     android:id="@+id/ListView04team"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
                     android:layout_marginTop="10dp"
                     android:background="@drawable/pm_cool_listproject_background" >

                 </ListView>


             </LinearLayout>
</ScrollView>

コードに何が欠けているのかわかりません。

4

5 に答える 5

1

4つのリストビューの高さをすべて設定できます..のように...

 <ListView
            android:id="@+id/lst_tree_hazard"
            android:layout_width="fill_parent"
            android:layout_height="80dp"       ///set the height based on your listview content
            android:scrollbars="none" >
 </ListView>
于 2012-12-03T11:47:17.147 に答える
1

Aは、スクロール要素内にあるlistviewべきではありません。逆もまた同様です。Google 開発者のコ​​メントをご覧ください。このビデオをご覧ください。

于 2012-12-03T10:56:06.653 に答える
0

ScrollViewを にする必要はありませんListViewRelativeLayoutの順番を指定して使いやすいと思いますListViews

于 2012-12-03T10:54:33.693 に答える
0

あなたはそのようにすることはできません!ただし、問題の解決策、単一のリスト内の複数のタイプのリスト項目があります。単一タイプのリスト項目の違い:

  • リスト項目のタイプを定義します。(header, list1_type, list2_type,... main_header?, main_footer?)、オーバーライドgetViewTypeCount()
  • オーバーライドgetItemViewType(...)
    • is index_of_header -> 0
    • is index_of_type1 -> 1
    • is index_of_type2 -> 2
  • より複雑getView(...)
    • アイテムのビュータイプを取得、ヒント: 作成済みの関数を使用
    • convertViewタイプに基づいてビューの作成をディスパッチします。引数が現在の項目タイプのビューであることを忘れないでください。null でない場合は、再利用する必要があります。

別の回答で述べたように、アダプターをマージするための独自の抽象クラスを作成できます。それは基本的に私が上で説明したことです。マージアダプターを使用できない場合があります。再帰構造ですが、 の使用を検討することをお勧めしExpandableListViewます。

于 2015-04-17T08:13:30.687 に答える
0

一般に、スクロール可能なものを同じ方向にスクロールする他のスクロール可能なもの内に配置して、結果を信頼できるものにすることはできません。ときどきこれが機能することもありますが (たとえばWebViewsa でViewPager)、それは例外であり、標準ではありません。

また:

、またはListView_ScrollView

addHeaderView()MergeAdapter などを使用するかどうかにかかわらず、ScrollViewの残りのすべてのコンテンツを ListView に移動します。

于 2012-12-03T11:00:35.013 に答える