我尝试使用2 for循环将包含列的行添加到表格布局中。当我手动完成,没有循环时,它可以工作,但现在它没有显示任何内容,也没有给我任何错误。
TableLayout dataTable = (TableLayout) findViewById(R.id.standingsData);
Integer[] dataOrder = {1, 0, 2, 3, 4};
for (int i=0; i < rssFeedStandings.size() ; i++)
{
TableRow dataTableRow = new TableRow(this);
TableLayout.LayoutParams dataTableRowParams = new TableLayout.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT);
dataTableRow.setLayoutParams(dataTableRowParams);
dataTableRow.setBackgroundResource(R.drawable.table_row);
for(int j=0; j < 5; j++) {
TextView textview = new TextView(this);
textview.setText(rssFeedStandings.get(i)[dataOrder[j]]);
textview.setLayoutParams(new TableRow.LayoutParams(j));
textview.setTypeface(tf2);
dataTableRow.addView(textview);
}
dataTable.addView(dataTableRow, dataTableRowParams);
Log.d(TAG, "Got here!!!");
}
任何帮助都会受到赞赏,对Android开发来说还是新手。