我已经在相对布局中动态创建了动态表格布局。我正在动态添加文本视图。我有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);
我是新来的Android。其实我已经试过了。它不起作用。你能确切地告诉我在哪里我应该把这个在我的代码? – user2151150 2013-03-13 12:40:19