手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >Android TableLayout数据列表的回显清空实现思路及代码
Android TableLayout数据列表的回显清空实现思路及代码
摘要:复制代码代码如下://数据列表的回显publicvoidshujuList(){ListcustomerList=dao.findALL()...

复制代码 代码如下:

//数据列表的回显

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 TableLayout数据列表的回显清空实现思路及代码】相关文章:

android 仿微信聊天气泡效果实现思路

Android 显示和隐藏输入法实现代码

android Setting中隐藏项实现原理与代码

android书架效果实现原理与代码

android 类似微信的摇一摇功能实现思路及代码

Android基站定位原理及实现代码

android 设置圆角图片实现代码

Android 再按一次返回键退出程序实现思路

Android开发笔记 TableLayout常用的属性介绍

android ListView内数据的动态添加与删除实例代码

精品推荐
分类导航