【发布时间】:2014-03-31 11:01:43
【问题描述】:
我有来自 exel 的列表视图:
try {
Workbook wb = WorkbookFactory.create(getAssets().open("bos.xls"));
Sheet sheet = wb.getSheetAt(0);
for(int i = 0; i < sheet.getPhysicalNumberOfRows(); i++) {
Row row = sheet.getRow(i);
Cell form1 = row.getCell(0);
Cell form2 = row.getCell(1);
Cell form3 = row.getCell(2);
IrrList = new ArrayList<HashMap<String, Object>>();
HashMap<String, Object> hm;
hm = new HashMap<String, Object>();
hm.put(Form1, form1.getStringCellValue());
hm.put(Form2, form2.getStringCellValue());
hm.put(Form3, form3.getStringCellValue());
IrrList.add(hm);
SimpleAdapter adapter = new SimpleAdapter(this, IrrList,
R.layout.list_item, new String[] { Form1, Form2, Form3 },
new int[] { R.id.text1, R.id.text2, R.id.text3 });
listView.setAdapter(adapter);
listView.setTextFilterEnabled(true);
}
} catch(Exception ex) {
return;
}
当我使用它时,我的列表视图中只有一个值。
怎么改?
我尝试在“HashMap hm;”之前添加这个:
for(int i1 = 0, l = IrrList.size(); i1 < l; i1++){
"I dont know what write here"
}
【问题讨论】:
标签: android excel listview arraylist hashmap