如何制作EditText的动态网格

时间:2012-07-30 05:02:11

标签: android-layout

我想创建edittext的动态网格,但它给了我一个IllegalStateException:

  

特定的孩子已经有了一个问题,你必须致电removeView()   先关于孩子的父母。

这是我的代码:

for (int x = 0; x < no_of_rows; x++)
{
    ll = new LinearLayout(this.getApplicationContext());
    ll.setLayoutParams(new LinearLayout.LayoutParams(
        LinearLayout.LayoutParams.FILL_PARENT,
        LinearLayout.LayoutParams.WRAP_CONTENT));
    ll.setOrientation(0);

    for(int y = 0; y < no_of_columns; y++){
        LinearLayout(this.getApplicationContext());
        this.edittext2.add(new EditText(this.getApplicationContext()));
        this.edittext2.get(y).setId(y);
        this.edittext2.get(y).setLayoutParams(new LinearLayout.LayoutParams(
                    LinearLayout.LayoutParams.FILL_PARENT
                    ,LinearLayout.LayoutParams.WRAP_CONTENT));
        this.edittext2.get(y).setMaxLines(1);
        this.edittext2.get(y).setText("Something");
        ll.addView(this.edittext2.get(y));
    }
    tlayout.addView(ll);
}

0 个答案:

没有答案