0
我本來的LinearLayout>滾動型> TableLayout和下面的代碼:滾動型內處理的LinearLayout
LinearLayout layout = (LinearLayout) View.inflate(this, R.layout.photos_layout, null);
setContentView(layout);
// TODO Auto-generated method stub
//get the tableLayout which we created in main.xml
tl = (TableLayout)findViewById(R.id.tableLayout1);
for(int i = 0; i < names.length; i++) {
//Create a new row to be added.
TableRow tr = new TableRow(this);
//Create text views to be added to the row.
TextView tv1 = new TextView(this);
TextView tv2 = new TextView(this);
//Put the data into the text view by passing it to a user defined function createView()
createView(tr, tv1, Integer.toString(i+1));
createView(tr, tv2, names[i]);
//Add the new row to our tableLayout tl
tl.addView(tr);
}
的問題是一個滾動視圖只能有一個孩子,所以如果我想添加更多的意見除了tableLayout我不能。爲了克服這個問題,我做了像LinearLayout> ScrollView> linearLayout> tableLayout的層次結構。但是,現在上面的代碼崩潰了應用程序。
我需要改變以填充我的表格,以及添加視圖到我新創建的linearlayout?
如果你有崩潰,你應該在這裏包含LogCat輸出 –
發佈崩潰日誌。和一些xmls? –
把你的錯誤記錄下來。 – blessenm