开发者

Addint textview to tableview dynamically

开发者 https://www.devze.com 2023-01-31 08:57 出处:网络
I want to populate the android tableview\'s rows with an array at runtime...开发者_开发问答 How to go about it....please advise

I want to populate the android tableview's rows with an array at runtime...开发者_开发问答 How to go about it....please advise

Thanks,


You can populate table view row's by reading tables child as follows:

TableLayout x = (TableLayout) findViewById(R.id.table_id);
for(int i=0;i<x.getChildCount();i++){
   TableRow tr = (TableRow) x.getChildAt(index);
   //Do here with table row, what u want to do.
}


TableLayout layout = (TableLayout) findViewById(R.id.table);
TableRow tr = new TableRow(context);

TextView view = new TextView(context);
view.setText("Test");
tr.addView(view);
layout.addView(tr);
0

精彩评论

暂无评论...
验证码 换一张
取 消