TextView 및 TableLayout이 포함 된 LinearLayout이 있습니다. 여기 내 XML 파일의 형식입니다.LinearLayout 내부의 TableLayout을 지우면 TextView 헤더가 제거됩니다.
<?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이다. 아무도 나를 도와주세요. 나는 안드로이드가 처음이다. 고맙습니다.
내가 말을 무슨 뜻인지 이해한다면? –