源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

Android TableLayout数据列表的回显清空实现思路及代码

  • 时间:2020-08-20 22:01 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:Android TableLayout数据列表的回显清空实现思路及代码
[u]复制代码[/u] 代码如下:
//数据列表的回显 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); } }
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部