I have some images in my assets folder, and I would like to load them into a ListView by using a SimpleAdapter.
I am referencing the images by their filenames, like: "my_image.jpg".
Here is some code:
ListView lv = (ListView) findViewById(R.id.list);
rows = new ArrayList<Map<String, Object>>();
for (String s : imageNames) {
rows.add(createRow(s));
}
SimpleAdapter adapter = new SimpleAdapter(
this,
rows,
R.layout.card_list_row,
new String[] {"Image"},
new int[] {R.id.list_row_image});
lv.setAdapter(adapter);
And the createRow method:
private Map<String, Object> createCardRow(String s) {
Map<String, Object> row = new HashMap<String, Object>();
row.put("Image", "file:///android_asset/" + s + ".jpg");
return row;
}
When I execute this, I get the following error:
02-12 20:01:22.615: I/System.out(17876): resolveUri failed on bad bitmap uri: file:///android_asset/my_image.jpg
And a FileNotFoundException. I obviously know that that image does exist in the assets folder. How can I reference it correctly?