這是我的代碼。我有一個帶有奇數行的文件。最後還是留下一個空白按鈕。如果我將其更改爲偶數行,它工作正常。 我希望它能讀取每行的行數並添加一個按鈕,而不管是否存在偶數或奇數行。 我在做什麼錯。 謝謝,while語句仍然添加空白行,即使是false?
// This builds the number of rows based on the number of lines in the file.
while (line != null){
TableRow tblRow = new TableRow(this);
tblRow.setPadding(5, 30, 5, 5);
table.addView(tblRow);
// iterates through the number of lines.
// filling each cell with a button with the name of each part in the file.
for (int col = 0; col < NUM_COL; col++) {
Button btn = new Button(this);
btn.setTextSize(14);
btn.setText(line);
btn.setOnClickListener(this);
tblRow.addView(btn);
line = reader.readLine();
}
};
你調試你的代碼? – Reimeus
我嘗試了一個catch,但沒有在IOException中顯示。如果我將閱讀器移出閱讀器,它就會永遠循環。 – vbneil54
這是我在調試模式下得到的東西 - 無法打開調試器端口(localhost:8624):java.net.ConnectException「連接被拒絕:連接」 – vbneil54