我有一个表格行现在可以正常工作,因为希望每一行都可以在代码中水平滚动。这是我的代码,当我将内容添加到水平滚动视图时,它会强制停止:
for (int i = 0; i <counter; i++) {
TableLayout table = (TableLayout) findViewById(R.id.tableLayout1);
final TableRow row = new TableRow(this);
HorizontalScrollView hsw = null;
final TextView t = new TextView(this);
t.setTextColor(Color.parseColor("#000000"));
t.setText(" "+filenames[i]+"");
t.setWidth(20);
t.setHeight(65);
t.setGravity(Gravity.BOTTOM|Gravity.LEFT);
t.setTextSize(15);
t.setTextColor(Color.WHITE);
TableLayout.LayoutParams tableRowParams=
new TableLayout.LayoutParams
(TableLayout.LayoutParams.FILL_PARENT,TableLayout.LayoutParams.WRAP_CONTENT);
row.setLayoutParams(tableRowParams);
row.addView(t);
hsw.addView(row);
table.addView(row,new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
}
谁能告诉我我的代码有什么问题?我做错了什么?坦克斯 :)