【发布时间】:2012-08-03 18:22:15
【问题描述】:
看看这段代码:
ArrayList<Object> row = data.get(position);
TextView idText = new TextView(this);
idText.setText(row.get(0).toString());
tableRow.addView(idText);
TextView storeText = new TextView(this);
idText.setText(row.get(1).toString());
tableRow.addView(storeText);
TextView maggiText = new TextView(this);
idText.setText(row.get(2).toString());
tableRow.addView(maggiText);
我必须手动创建一个TextView,将其设置为某个字符串,然后传递它。有没有一种方法可以直接将字符串传递给可以放入for 循环的行?
我正在寻找这种方法来解决可扩展性问题。
【问题讨论】:
-
听起来像ArrayAdapter 是您所需要的。你可以覆盖
getView()。