同じアクティビティで2つのListViewを絞り込もうとして、ピクルスに陥りました。これは、標準 (垂直) LinearLayout に含まれる 2 つの個別の ListFragments を使用して機能します。
問題は、2 つのリストを合わせると画面より長くなり、2 番目のリストが部分的に隠れてしまうことです。視覚的には、ユーザーは画面全体をドラッグして 2 番目のリストを表示することを期待しています。ただし、2 つのリストには独自の内部スクロール機能があり、画面全体を 1 つの部分としてスクロールすることはできません。
幸いなことに、リストには実際には非常に少ない項目しか含まれていません (平均でそれぞれ 5 つ)。したがって、理論的には、代わりにいくつかの LinearLayouts コンテナーを設定できます。問題は、リストによって表示されるデータが Cursor から取得され、動的であることです。CursorAdapter の newView() および bindView() メソッドは認識していますが、アダプターを ListView ではなく LinearLayout コンテナーに接続する方法がよくわかりません。つまり、CursorAdapter は、カーソルで見つかった 5 つの項目から 5 つの行項目を作成する必要があることをどのように認識しますか? カーソル項目を反復処理して LinearLayout コンテナーに項目を作成するループはどこで作成すればよいですか? Cursor のデータが変更されたときに LinearLayout のコンテンツを更新するにはどうすればよいですか? 私が見つけたすべての例は、これらの問題を ListActivity によって提供される ListView にきちんとラップしています。
よくわかりません!
マヌー
編集: breceivemail の提案に従うときの (Fragment)Activity の xml レイアウトは次のとおりです。コメント アウトされているのは、breceivemail の提案の前の元の LinearLayout コンテナーです。また、アクティビティ全体がTabHostに含まれていることにも注意してください。ただし、それが目前の問題に影響を与えるかどうかはわかりません。
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<!--
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
-->
<TextView android:id="@+id/title"
android:textSize="36sp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/SelectPlayer"/>
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/Playing"
android:textSize="18sp"
android:textStyle="bold"
android:textColor="#000000"
android:background="#999999"/>
<fragment android:name="com.myDomain.myApp.PlayerListFragment"
android:id="@+id/playing"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/Reserve"
android:textSize="18sp"
android:textStyle="bold"
android:textColor="#000000"
android:background="#999999"/>
<fragment android:name="com.myDomain.myApp.PlayerListFragment"
android:id="@+id/reserve"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>