package com.example.tablelayout;
import android.app.*;
import android.os.*;
import android.widget.*;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TableLayout tl = new TableLayout(this);
setContentView(tl);
TableRow[] tr = new TableRow[6];
TextView[] tv = new TextView[6];
Button[] bt1 = new Button[6];
Button[] bt2 = new Button[6];
for(int i=0; i<tr.length; i++)
{
tr[i] = new TableRow(this);
tv[i] = new TextView(this);
tv[i].setText("物品"+ i + "-------");
bt1[i] = new Button(this);
bt1[i].setText("購買");
bt2[i] = new Button(this);
bt2[i].setText("取消購買");
tr[i].addView(tv[i]);
tr[i].addView(bt1[i]);
tr[i].addView(bt2[i]);
tl.addView(tr[i]);
}
}
留言列表