我在相对布局中动态创建了动态表格布局。我正在动态添加文本视图。我有 9 个字段要显示。如何在其中放置水平和垂直滚动条?
代码:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view);
// Show the Up button in the action bar.
setupActionBar();
TableLayout tableLayout = new TableLayout(getApplicationContext());
TableRow tableRow;
TextView textView;
............................
............................
............................
for (int i = 0; i < rows; i++)
{ //4 rows
tableRow = new TableRow(getApplicationContext());
for (int j = 0; j < columns; j++)
{ //3 columns
textView = new TextView(getApplicationContext());
textView.setText(temp[k++]);
textView.setPadding(15, 15, 15, 15);
tableRow.addView(textView);
}
tableLayout.addView(tableRow);
}
setContentView(scrollView);
setContentView(tableLayout);