0

私は次のようなビューを作成しようとしています:

テーブルレイアウト

...2つの固定ヘッダーがあります。画像に示すように、テーブル全体のレイアウトはスクロール可能で、内部テーブルビューもスクロール可能です。ヘッダーとデータは動的です。そして、header-2までスクロールすると、header-1ではなくheader-1のアイテムが非表示になります。

4

3 に答える 3

0
 <?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" />

于 2012-07-31T10:17:29.820 に答える
0

このためには、アダプタクラスを維持する必要があります。必要に応じて要素を揃えることができます

これを確認してください。

そしてこれ

于 2012-07-31T10:19:29.160 に答える
0

ListViewを使用せずに簡単に実現する方法を説明できます。データ量が少ない場合は、ListViewを使用しないでください。効率に影響します。

ステップ1 :

重み属性を利用し、2つのヘッダーに等しい半分を与えます

ステップ2:

ヘッダー名は静的で、スクロールビュー内に1つのTableLayoutを作成します

ステップ3:

動的としてTableRowを作成し、個別または同じレイアウトで、テーブル行をTableLayoutに動的に追加します。

取得する2番目のヘッダーについても同じことを繰り返します。

Dynamic TableLayoutについては、このリンクを確認してください

于 2012-07-31T10:32:45.873 に答える