私は、動的タブロー/テーブルレイアウトから生成された1つの画面上に2つの領域を作成しようとしています。Android TableLayout - "指定された子はすでに親を持っています。最初に親のremoveView()を呼び出す必要があります。"
最初のtablelayoutには6つのtextview要素を持つtablerowがあります。
第2のテーブルレイアウトには、それぞれ6つのボタンがある2つのタブローがあります。
各ボタン/テキストビューはxmlファイルから購入されます。
問題この2つのテーブルを実行しようとすると、titleに記載されているエラーがスローされていることがあります。あなたの時間のために、以下の行
tablerow.addView(View1);
CODE
Layout1 = (TableLayout) findViewById(R.id.scoring_tableLayout1);
Layout2 = (TableLayout) findViewById(R.id.scoring_tableLayout2);
inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
text = new TextView[6];
TableRow tablerow1 = new TableRow(this);
for (int i = 0; i < 6; i++) {
View1 = (View) inflater.inflate(R.layout.layout1, null);
text[i] = (TextView) endValueView.findViewById(R.id.textView_item);
tablerow.addView(View1);
}
Layout1.addView(tablerow1);
button = new Button[12];
for (int i = 0; i < 2; i++) {
TableRow tablerow2 = new TableRow(this);
for (int j = 0; j < 6; j++) {
ButtonView = (View) inflater.inflate(R.layout.button, null);
button[j] = (Button) ButtonView
.findViewById(R.id.scoring_arrow_score_button);
button[j].setText("some text");
tablerow2.addView(ButtonView);
}
Layout2.addView(tablerow2);
}
おかげでエラーを.IT
私は2番目のループ内で同じidボタンを呼び出しています。それはtextviewsのために異なって動作しますか? –