Android TableLayout数据列表的回显清空实现思路及代码
//数据列表的回显
public void shujuList(){
List 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
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);
}
}相关阅读:
iOS应用中使用Auto Layout实现自定义cell及拖动回弹
Android中调用系统的文件浏览器及自制简单的文件浏览器
JS模拟bootstrap下拉菜单效果实例
Android开发中使用Volley库发送HTTP请求的实例教程
CSS怎么将背景图左移/上移/右移10px
微软招聘启事引瞩目:Windows或将融合安卓应用
解析Java线程编程中的线程安全与synchronized的使用
javascript 构造函数方式定义对象
升级Win10后如何重新安装系统?几点流程和注意事项介绍
MSSQL分页存储过程完整示例(支持多表分页存储)
win10手机预览版10080怎么快速切换输入键盘
jQuery插件expander实现图片翻转特效
iOS开发之UIKeyboardTypeNumberPad数字键盘自定义按键
CHECKBOX 的全选、取消及跨页保存的实现方法