TextViewとTableLayoutが埋め込まれたLinearLayoutがあります。これが私のxmlファイルのフォーマットです。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<TextView
android:id="@+id/txtHeader"
android:layout_width="match_parent"
android:text="Header" />
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1">
<TableRow>
<!-- Column 1 -->
<TextView
android:id="@+id/row1Item1"
android:text="Column1" />
<!-- Column 2 -->
<TextView
android:id="@+id/row1Item2"
android:text="Column2" />
</TableRow>
</TableLayout>
</LinearLayout>
テーブルに動的に行を追加しています。更新を受け取るたびに、テーブルをクリアして新しい情報を書き込む必要があります(行数は変数です)。ですから、更新が必要なときはいつでも、最初のステップとしてテーブルをクリアしようとしています。
ll = (LinearLayout)findViewById(R.id.wlayout);
tb = (TableLayout)findViewById(R.id.wtable);
private void on Update(){
tb.removeAllViewsInLayout();
Create table dynamically..
}
しかし、それは私のテキストヘッダーも削除しています。ll.removeView(tb)も試しました。ここで、llはLinearLayoutです。誰か助けてくれませんか。私はAndroidを初めて使用します。ありがとうございました。