Android layout 如何创建EditText的动态网格

Android layout 如何创建EditText的动态网格,android-layout,Android Layout,我想创建edittext的动态网格,但它给了我一个非法状态异常: 特定子级已经有一个prent,您必须调用removeView() 先在孩子和父母身上 这是我的密码: for (int x = 0; x < no_of_rows; x++) { ll = new LinearLayout(this.getApplicationContext()); ll.setLayoutParams(new LinearLayout.LayoutParams( Linea

我想创建edittext的动态网格,但它给了我一个非法状态异常:

特定子级已经有一个prent,您必须调用
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);
}
for(int x=0;x