`
v5browser
  • 浏览: 1140253 次
社区版块
存档分类
最新评论

Android TableLayout数据列表的回显清空

 
阅读更多
//数据列表的回显
public void shujuList(){
List<Customer> customerList = dao.findALL();
TableLayout tl = (TableLayout) findViewById(R.id.tlLayout);
Log.i(">>>", String.valueOf(tl.getChildCount()));
int j = tl.getChildCount();
if(j>1){
/*for(int i=0;i<j;i++){
tl.removeView(tl.getChildAt(j-i));//必须从后面减去子元素
}*/
for(int i=j;i>0;i--){
tl.removeView(tl.getChildAt(i));//必须从后面减去子元素
}
}
TableRow row = null;
for(Customer c : customerList){
row = new TableRow(this);
//id
TextView tvId = new TextView(this);
tvId.setText(c.id + "");
row.addView(tvId);
//name
TextView tvName = new TextView(this);
tvName.setText(c.name);
row.addView(tvName);
//age
TextView tvAge = new TextView(this);
tvAge.setText(c.teleNumber + "");
row.addView(tvAge);
tl.addView(row);
}


}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics