0
我正在嘗試創建類似Android WordSearch應用程序的地方,它在網格中顯示一系列字母。我最初使用GridView,但不能同時垂直水平滾動&。因此切換到tablelayout。現在我想給這個樣子的,如下:使用單個TableRow和單個TextView創建單個字符的網格
現在,當我使用TableLayout,它讀取單個垂直整個數據僅一行。
我想知道,如果我們可以依次通過單一的TableRow和單一的TextView和創建前一種觀點:以下是我的代碼
int index = 0;
TableLayout tableLayout = new TableLayout(getApplicationContext());
tableLayout.setColumnStretchable(2, true);
TableRow tableRow;
TextView textView;
for (int i = 0; i < 50; i++) // this reads 50 chars from text file
{
tableRow = new TableRow(getApplicationContext());
for (int j = 0; j < 35; j++) //this creates 35 repetitions of above tablerow
{
textView = new TextView(getApplicationContext());
textView.setText(split3(numbers)[i]);
textView.setTextSize(19);
textView.setPadding(1, 2, 0, 2);
textView.setTypeface(null, Typeface.BOLD);
tableRow.addView(textView);
index = index + 1;
}
tableLayout.addView(tableRow);
}
scrollView = new HScroll(GridActivity.this);
scrollView.addView(tableLayout);
VSC = new VScroll(GridActivity.this);
VSC.addView(scrollView);
setContentView(VSC);
}
您爲表格行或表格佈局設置了哪個方向? – Piyush
肖像本身。儘管我已經設法把它拉開....謝謝 –