コードを使用してテーブル レイアウトを動的に生成する必要があります。表示させることができません。テーブル生成コード セグメントを基本的な部分まで減らして試してみましたが、この非常に単純化されたバージョンでさえ機能しません (つまり、表示されません)。誰かが私が間違っていることを指摘できますか? ありがとう。
public class TableByCodeTest extends Activity{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TableLayout tableLayout = new TableLayout(this);
tableLayout.setLayoutParams(
new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
TableRow firstTableRow = new TableRow(this);
firstTableRow.setLayoutParams(
new TableRow.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
TextView title = new TextView(this);
title.setText(R.string.title);
title.setLayoutParams(
new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
firstTableRow.addView(title);
tableLayout.addView(firstTableRow);
setContentView(tableLayout);
}
}