//数据列表的回显
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有所帮助
程序源代码下载 博文链接:https://greatwqs.iteye.com/blog/1045709
TableLayout,实现动态添加和删除行,判断行中的数据是否含有空值,可以手动地输入数据,也可以选择数据添加在表格中,并实现统计表格中的数据。
Android使用TableLayout动态布局实例: http://blog.csdn.net/lk_blog/article/details/7436380
android 利用TableLayout自动生成表格
TableLayout 简单程序,但不常用的话容易忘记。特此发布,以备不时之需
android固定头部和左侧表格实现,可以实现纵向合并,不含TableLayout等布局,简单易懂
Android入门第五篇之TableLayout (二).docx
Android-TableLayout-Example Android-TableLayout-Example
看到很多在安桌上做表格的例子,总感觉不太理想,所以自己做了一个,感觉比较好用,供参考。 (图片在哪儿上传?)
NULL 博文链接:https://hanllove001.iteye.com/blog/1185546
TableLayout实现gridview嵌套gridview效果.md
利用TableLayout自定义可点击表格
TableLayout 简单程序,但不常用的话容易忘记。特此发布,以备不时之需
NULL 博文链接:https://yangguangfu.iteye.com/blog/678977
表格布局的标签是TableLayout,TableLayout继承了LinearLayout。所以它依然是一个线性布局,通过本文给大家介绍Android TableLayout表格布局,感兴趣的朋友一起学习吧
本文初步讲述了Android中TableLayout的应用,对Android初学者有一定的学习借鉴价值。具体如下: TableLayout跟TableLayout 是一组搭配使用的布局,TableLayout置底,TableRow在TableLayout的上面,而Button、TextView...
用TableLayout实现九宫格参差不齐的排版用TableLayout实现九宫格参差不齐的排版