我讓我的充氣器顯示了我想要的行數。我無法將文本插入到充氣機內的每個文本視圖中。它只填充第一個TextView並將其餘部分留空。我嘗試使用數組,但一直得到運行時錯誤將文本添加到TextView裏面的充氣器
for (int i = 1; i <= numberOfGuests; ++i) {
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.row_per_person, table);
float numberInsertedForPerson = (float) (Math.round(tipPerPersons * 100.0)/100.0);
String sTipPerPerson = Float.toString(numberInsertedForPerson);
tipPerPerson = (TextView) findViewById(R.id.tipPerPerson);
tipPerPerson.setText(sTipPerPerson);
}
當我添加false時,infalter不再有效。 – Aaron
它的工作原理,我只是忘記提及另一個事實,那就是當你傳遞false時,它不會被添加到父ViewGroup中。檢查我最近的編輯 - 你需要在最後調用'addView()'。 – kcoppock
謝謝,它是我第一個在一年半內完成的Android項目,我不記得它很多,並且不在工作中使用java – Aaron