如何在Android中动态定义tablelayout?

时间:2011-08-18 05:06:42

标签: android layout

如何在此列中动态创建表格行应采用水平方式,并且每行应在Android中用单行或不同颜色分隔。

1 个答案:

答案 0 :(得分:3)

查看以下代码。 layout是表格Layout; rowColor是您可以为行背景设置的颜色

TableRow tr1=new TableRow(this);
TextView title=new TextView(this);
title.setText(tit);
title.setTextColor(Color.rgb(0,0,0));
tr1.addView(title,150,30);
tr1.setBackgroundColor(rowColor);
layout.addView(tr1);