Android TableLayout数据列表的回显清空实现思路及代码
2013-04-26 16:35
761 查看
//数据列表的回显
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 使用Intent传递数据的实现思路与代码
- Android列表实现(3)_自定义列表适配器思路及实现代码
- android好看表单界面设计(TableLayout)及查询数据列表显示1
- Android中获取网页表单中的数据实现思路及代码
- android好看表单界面设计(TableLayout)及查询数据列表显示2
- Android表格布局TableLayout简单实现(Java动态添加,设置边框,删除数据(单行,多行))
- Android中获取网页表单中的数据实现思路及代码
- 代码实现Layout android:layout_alignParentRight
- JS小功能(操作Table--动态添加删除表格及数据)实现代码
- [Android]使用二维表格实现 TableLayout 跨行(转)
- Android采用ListView实现数据列表显示
- jQuery实现清空table表格除首行外的所有数据
- Android使用RecyclerView实现列表数据选择操作
- Android清空编辑框数据功能的实现
- Android Layout 之 RelativeLayout,代码实现相对布局
- Android TableLayout 实现边框
- Android应用开发之TableLayout (表格布局)+信息列表案例
- android动画(3)layout动画,layoutChanged动画及算定义它,ListViewActivity的Layout动画(代码和xm配置两种实现l)