私は次のようなビューを作成しようとしています:
...2つの固定ヘッダーがあります。画像に示すように、テーブル全体のレイアウトはスクロール可能で、内部テーブルビューもスクロール可能です。ヘッダーとデータは動的です。そして、header-2までスクロールすると、header-1ではなくheader-1のアイテムが非表示になります。
私は次のようなビューを作成しようとしています:
...2つの固定ヘッダーがあります。画像に示すように、テーブル全体のレイアウトはスクロール可能で、内部テーブルビューもスクロール可能です。ヘッダーとデータは動的です。そして、header-2までスクロールすると、header-1ではなくheader-1のアイテムが非表示になります。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="list1" />
<ListView
android:id="@+id/list1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:scrollbars="vertical" />
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#FF4500" />
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="list2" />
<ListView
android:id="@+id/con_listView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:scrollbars="vertical" />
ListViewを使用せずに簡単に実現する方法を説明できます。データ量が少ない場合は、ListViewを使用しないでください。効率に影響します。
ステップ1 :
重み属性を利用し、2つのヘッダーに等しい半分を与えます
ステップ2:
ヘッダー名は静的で、スクロールビュー内に1つのTableLayoutを作成します
ステップ3:
動的としてTableRowを作成し、個別または同じレイアウトで、テーブル行をTableLayoutに動的に追加します。
取得する2番目のヘッダーについても同じことを繰り返します。