我正在以编程方式创建表格行,并且希望将之前创建的视图放入行中。有什么办法可以做到吗?如何在Android中的表行中放置自定义视图?
for (current = 0; current < rapor1.length; current++)
{
TableRow tr = new TableRow(this);
tr.setId(100+current);
tr.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
TextView f1 = new TextView(this);
f1.setId(200+current);
f1.setText(rapor1[current]);
f1.setTextColor(Color.BLACK);
f1.setWidth(100);
tr.addView(f1);
DrawView dv = new DrawView(this);
tr.addView(dv);
它应该工作,但有些事情是错误的。
什么是错的任何观点及?编译错误?运行时错误?提供更多信息 – theAlse
它不会在那里添加。它不起作用 – mucisk