【发布时间】:2013-11-30 11:42:17
【问题描述】:
我尝试将一张照片加载到使用 HashMap 填充的自定义列表视图中。
这里有一部分正在使用的代码......
File f = new File(Environment.getExternalStorageDirectory()+/path/Cache/photo.png");
FileInputStream is = null;
try {
is = new FileInputStream(f);
} catch (FileNotFoundException e) {
Log.i("file not found","not found");
}
Bitmap bmp =BitmapFactory.decodeStream(is);
//Bitmap bmp =BitmapFactory.decodeFile((PATH + "resene.png"));
map.put(TAG_PICTURE, bmp );
// adding HashList to ArrayList
paintShopsList.add(map);
并使用 simpleadapter 填充列表视图
adapter = new SimpleAdapter(ShopSearchActivity.this,
paintShopsList, R.layout.list_row_search_shop, new String[]
{TAG_PICTURE},
new int[] {R.id.list_image });
// updating listview
setListAdapter(adapter);
如果我使用 drawable 将图像放到 hashmap 中,它可以工作,但是当我想从 SdCard 中放入图像时发生此错误
【问题讨论】:
-
您是否添加了从外部存储读取的权限?
标签: android listview hashmap android-sdcard simpleadapter