ボタン 1 から 9 を作成し、それをループで実行したい。しかし、3 カウントごとに、新しい LinearLayout を作成したいと考えています。
final LinearLayout[] ll2 = new LinearLayout[10]; // create an empty array;
for(int i=1; i<=9;i++)
{
Button btnNums = new Button(this);
final LinearLayout[] ll2 = new LinearLayout[10]; // create an empty array;
for(int i=1; i<=9;i++)
{
Button btnNums = new Button(this);
btnNums.setText(i+"");
ll.addView(btnNums);
if(i%3==0){
ll2[i] = ll;
ll = null;
}
}
layout.addView(ll2[0]);
btnNums.setText(i+"");
ll.addView(btnNums);
if(i%3==0){
ll2[i] = ll;
ll = null;
}
}
layout.addView(ll2[0]);
これは動作しません。エラーは発生しませんが、アプリを実行すると動作が停止します。どうしたの?