プログラムによる方法で、レイアウト xml ファイルで定義されたテーブルにデータを入力したいと考えています。すべての属性が設定されたヘッダーを定義する単一行でテーブルを定義しました。今、テーブルのヘッダー行を新しいコンテンツで複製できる方法を知りたいです。
インフレータの inflate(int,view) メソッドを使用してみましたが、実行時にエラーが表示されました。
テーブルを定義するレイアウト ファイルの XML コードを次に示します。
<?xml version="1.0" encoding="utf-8"?>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="0,1,2"
android:id="@+id/tLayout"
>
<TableRow
android:layout_width="fill_parent"
android:id="@+id/tRow">
<TextView
android:id="@+id/name"
android:padding="3dip"
android:gravity="left"
android:text="Name"
/>
<TextView
android:id="@+id/address"
android:padding="3dip"
android:gravity="left"
android:text="Address"
/>
<TextView
android:id="@+id/age"
android:padding="3dip"
android:gravity="left"
android:text="Age"
/>
</TableRow>
</TableLayout>