나는 코드에서 테이블 행을 대체하는 이상한 문제가있어.코드가 안드로이드 변경 tableLayout 작동하지 않습니다
내 XML 코드는 다음과 같습니다
활동이 만들어<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/columnheadings"
android:layout_height="wrap_content"
android:layout_width="fill_parent"/>
<ListView
android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:dividerHeight="2px"
/>
...
</LinearLayout>
, 내가 성공적으로 "columnheadings"는 TableLayout을에 TableRow 삽입 할 수 있습니다
table = (TableLayout)findViewById(R.id.columnheadings);
table.removeAllViews();
TableRow tr = new TableRow(this);
TextView tv = new TextView(activity);
tv.setText("asdf");
tr.addView(tv);
table.addView(tr);
table.postInvalidate();
내용을 (그리고 너비)가 동적으로 계산됩니다.
이제 ListView의 어댑터 내에 업데이트가있을 때 TableLayout을 다시 그리기를 원합니다. 이를 위해 활동에 대한 참조로 어댑터를 작성합니다.
어댑터에서 성공적으로 변경할 수 있습니다. 열의 텍스트
나는 (성공없이) 수행하려고 무엇 :
TableLayout tableLayout = (TableLayout)activity.findViewById(android.app.R.id.columnheadings);
tableLayout.removeAllViews();
TableRow row=new TableRow(activity);
TextView tv = new TextView(activity);
tv.setText("test");
row.addView(tv);
tableLayout.addView(row);
tableLayout.postInvalidate();
불행하게도, 발생 유일한 것은 현재 테이블 행의 제거이다. 새 행은 어댑터의 tableLayout에 추가되지 않습니다.
제안 사항?