我想在Android中创建一个包含2个列和可变行数的表。 我已经用TableLayout尝试了4个小时,但是我的布局一直搞乱了。 我想要这样的布局: table http://dl.dropbox.com/u/62842168/tabel.JPG
我现在有了这个代码:
while(b && it.hasNext()){
itr = it.next();
String nodeText1 = itr.child(0).text().toString();
if(nodeText1.contains("dag")){break;}
String prijs = itr.select("td").get(1).text().toString();
TableRow tr = new TableRow(this);
TableLayout.LayoutParams rowLp = new TableLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.MATCH_PARENT);
TextView t = new TextView(this);
t.setText(nodeText1);
TextView p = new TextView(this);
p.setText("€ "+prijs);
TableRow.LayoutParams cellLp1 = new TableRow.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
cellLp1.gravity = Gravity.LEFT;
TableRow.LayoutParams cellLp2 = new TableRow.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
cellLp2.gravity = Gravity.RIGHT;
tr.addView(t,cellLp1);
tr.addView(p,cellLp2);
tabel.addView(tr,rowLp);
谁能告诉我我做错了什么?