Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/207.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在android中从SD卡将图像加载到定制的listview?_Android_Listview_Hashmap_Android Sdcard_Simpleadapter - Fatal编程技术网

如何在android中从SD卡将图像加载到定制的listview?

如何在android中从SD卡将图像加载到定制的listview?,android,listview,hashmap,android-sdcard,simpleadapter,Android,Listview,Hashmap,Android Sdcard,Simpleadapter,我尝试将照片加载到自定义列表视图中,该视图使用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

我尝试将照片加载到自定义列表视图中,该视图使用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,它会工作,但当我想从SD卡放入图像时,会发生此错误


不要使用新的输入流,请尝试:
BitmapFactory.decodeStream(getContentResolver().openInputStream(uri))

您添加了从外部存储读取的权限吗?