public class TestForm extends Activity {
/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.testpage);
        final EditText txtShow = (EditText)this.findViewById(id.testEditText);
        Intent intenter = getIntent();
        txtShow.setText(intenter.getStringExtra("res").toString());
        
        Button btn1=(Button)this.findViewById(id.testBtnOk);
        btn1.setOnClickListener(new OnClickListener() { 
            public void onClick(View v) {
             CreateView();
            }
        });
    }
    
    public void CreateView()
    {
     TableLayout tl = (TableLayout)findViewById(R.id.testTblay);
       /* Create a new row to be added. */
        TableRow tr = new TableRow(this);
        tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
        tl.addView(tr);
        /* Create a TextView to be the row-content. */
        TextView txt1 = new TextView(this);
        txt1.setText("我");
        txt1.setId(0);
        txt1.setLayoutParams(new LayoutParams(
                  LayoutParams.FILL_PARENT,
                  LayoutParams.WRAP_CONTENT));
        /* Add TextView to row. */
        tr.addView(txt1);
        tl.setShrinkAllColumns(true);  
    }
}XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >    <EditText
        android:id="@+id/testEditText"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:orientation="vertical" >        <requestFocus />
    </EditText>
    <Button
        android:id="@+id/testBtnOk"
        android:layout_width="126dp"
        android:layout_height="wrap_content"
        android:layout_marginRight="60dp"
        android:text="新增"
        android:orientation="vertical" />     <TableLayout
        android:id="@+id/testTblay"
        android:layout_width="wrap_content"
        android:layout_height="420dp"      
        android:shrinkColumns="0" >
    
   </TableLayout>
</LinearLayout>