我尝试了几乎所有可能的方法,将图像从存储的文件路径设置为image-view
。从文件路径设置位图到imageview不起作用
没有一个工作。 图像是从其他活动的图库中选择的,图像路径存储在数据库中。
图像是类型的.JPG存储在数据库的路径而没有任何扩展的.jpeg .PNG
图像路径
eg. /external/storage/media/carimagename
当我尝试使用此代码图像设置为imageview
没有错误,但图像未设置。
for(int i=0;i<n;i++)
{
Bitmap pic = BitmapFactory.decodeFile(listview_arraypro1[i]);
carpict.setImageBitmap(pic);
/// File imgFile =new File("listview_arraypro1[i]");
// carpict.setImageBitmap(BitmapFactory.decodeFile(imgFile.getAbsolutePath()));
// Bitmap carpic = BitmapFactory.decodeStream(is);
// carpic = Bitmap.createScaledBitmap(carpic, 72, 70, false);
}
我怎么可以设定路径格式/external/storage/media/carimagename
图像到imageview
?
即时通讯使用下列以获得在以前的活动图像路径
Uri selectedImage = imageReturnedIntent.getData();
String selectedImagePath = selectedImage.getPath();
我收到来自selectedImagePath走错路?
这是我得到了使用此路径它没有MNT/SD卡
private String getRealPathFromURI(Uri contentURI) {
Cursor cursor = getContentResolver().query(contentURI, null, null, null, null);
if (cursor == null) { // Source is Dropbox or other similar local file path
return contentURI.getPath();
} else {
cursor.moveToFirst();
int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA);
return cursor.getString(idx);
}
}
File imageFile = new File(getRealPathFromURI(selectedImage));
String path= imageFile.toString();
没有答案工作:(还尝试给图像路径字符串img _path =“/ storage/sdcard0/Fbt/xylo.jpg”;仍然没有工作! – Metalhead1247
你有没有为它添加权限? – Piyush
哪个特权? – Metalhead1247