0

アドバイスをお願いします。混合要素を含む動的レイアウトを作成したい[テキスト][チェックボックス][ボタン][テキスト][チェックボックス][ボタン][テキスト][チェックボックス][ボタン].....。

サンプルコードを教えてください。

4

1 に答える 1

2
final TableLayout Tlayout = new TableLayout(getApplicationContext());  
Trow = new TableRow(getApplicationContext()); 

checkBox = new CheckBox(getApplicationContext());
Trow.addView(checkBox);

button = new Button(getApplicationContext());
button.setText("Button");
Trow.addView(button);

textBox = new EditText(getApplicationContext());
textBox.setText("default_value");
Trow.addView(textBox);

Tlayout.addView(Trow);

このコードは、動的フォーム要素の作成に役立つ場合があります。

于 2010-06-09T06:49:34.483 に答える