如何在android中生成动态文本视图? [英] how to generate dynamic textview in android?
本文介绍了如何在android中生成动态文本视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要这样的东西
for(i=0; i<10; i++) {
Textview tx[i] = new TextView(this);
tx[i].setText("Data")
TableRow tr[i] = new TableRow(this);
tr[i].addView(tx);
// and then adding table row in tablelayout
}
谁能给我一个小例子
推荐答案
TextView[] tx = new TextView[10];
TableRow[] tr = new TableRow[10];
for(i=0; i<10; i++) {
tx[i] = new TextView(this);
tx[i].setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
tx[i].setText("Data")
tr[i] = new TableRow(this);
tr[i].setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
tr[i].addView(tx[i]);
// and then adding table row in tablelayout
}
这篇关于如何在android中生成动态文本视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文