展会信息港展会大全

Android TableLayout数据列表的回显清空
来源:互联网   发布日期:2015-10-13 15:22:54   浏览:2619次  

导读://数据列表的回显public void shujuList(){List<Customer> customerList = dao.findALL();TableLayout tl =...

//数据列表的回显

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);

}

}

赞助本站

人工智能实验室

相关热词: android开发 教程

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港