国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android TableLayout數據列表的回顯清空實現思路及代碼

2020-04-11 12:27:26
字體:
來源:轉載
供稿:網友
復制代碼 代碼如下:

//數據列表的回顯
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);
}
}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 泗水县| 晴隆县| 澄迈县| 文山县| 龙岩市| 亳州市| 梅河口市| 饶阳县| 定陶县| 博兴县| 河源市| 阆中市| 榕江县| 白河县| 岑巩县| 青岛市| 阳曲县| 扎赉特旗| 新兴县| 新民市| 天柱县| 永嘉县| 会泽县| 宁阳县| 柘荣县| 鹿邑县| 湄潭县| 望都县| 连云港市| 平顶山市| 东阳市| 平顺县| 营山县| 镇江市| 盐山县| 日照市| 广饶县| 天台县| 洪江市| 华坪县| 喀喇沁旗|