所以无论我做什么,毕加索和滑翔都不能将图像文件或图像字符串路径加载到图像视图中。
我试过了。
这是我的代码:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data)
{
Uri selectedImage = data.getData();
String[] filePathColumn = {MediaStore.Images.Media.DATA};//Array size of 1, and we put in a string
Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
user_image_path = cursor.getString(columnIndex);//here we have our image path.
cursor.close();
File tempFile2 = new File(selectedImage.getPath());
//Toast.makeText(this, "I got your image " + user_image_path, Toast.LENGTH_SHORT).show();
myImageView = (ImageView) findViewById(R.id.cameraActivity_ImageView);
//Picasso.with(TakePhotoActivity.this).load(selectedImage).fit().centerCrop().into(myImageView);
Glide.with(this).load(new File(selectedImage.getPath())).centerCrop().into(myImageView);
}
}
所以我试过:
1)Picasso.with(TakePhotoActivity.this).load(user_image_path).fit().centerCrop().into(myImageView);
2)Glide.with(this).load(user_image_path).centerCrop().into(myImageView);
3)Picasso.with(TakePhotoActivity.this).load(tempFile2).fit().centerCrop().into(myImageView);
4)Glide.with(this).load(tempFile2).centerCrop().into(myImageView);
5)Picasso.with(TakePhotoActivity.this).load(selectedImage.getPath())).fit().centerCrop().into(myImageView);
6)Glide.with(this).load(selectedImage.getPath())).centerCrop().into(myImageView);
他们都没有工作。如果我使用:
Picasso.with(TakePhotoActivity.this).load(selectedImage).fit().centerCrop().into(myImageView);
Glide.with(this).load(selectedImage).centerCrop().into(myImageView);
上面这两个与 Uri selectedImage 变量一起使用,但其他都不起作用。那么为什么其他选项不起作用以及如何让它们起作用,因为理想情况下我想使用图像路径字符串。
希望大家能帮忙!我完全被这个难住了。