2011-03-06 41 views

回答

0

這裏是TableLayout

+0

不幸的是,很難看到如何使用該方法插入動態數據。 – 2011-03-06 09:02:54

4

使用的例子一個簡單的例子:

public class MainActivity extends Activity 
{ 
    @Override 
    public void onCreate(Bundle savedInstanceState) 
    { 
     super.onCreate(savedInstanceState); 
     TableRow.LayoutParams params = new TableRow.LayoutParams(100, 100); 
     TableLayout table = new TableLayout(this); 
     for (int i = 0; i < 3; i++) { 
      TableRow row = new TableRow(this); 
      for (int j = 0; j < 3; j++) { 
       TextView text = new TextView(this); 
       text.setLayoutParams(params); 
       text.setText(String.format("(%d, %d)", i, j)); 
       row.addView(text); 
      } 
      table.addView(row); 
     } 
     setContentView(table); 
    } 
} 

如果你能擺脫它,GridViewListView可以更容易使用適配器,例如ArrayAdapter工作和CursorAdapter