我正在尝试在ImageView中显示URI中的图像。我尝试了一些东西,但总是得到错误'无法解决方法setImageUri(android.net.uri)'。
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_PIC_REQUEST) {
Uri receiptUri = Uri.parse("/Kassenzettel/3.bmp");
ImageView receiptImage = (ImageView) findViewById(R.id.result_image);
receiptImage.setImageUri(receiptUri);
}
}
答案 0 :(得分:1)
这对我有用:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_PIC_REQUEST) {
ImageView receiptImage = (ImageView) findViewById(R.id.result_image);
Uri receiptUri = Uri.parse("/Kassenzettel/3.bmp");
try {
InputStream inputStream = getContentResolver().openInputStream(receiptUri);
Drawable drawable = Drawable.createFromStream(inputStream, null);
receiptImage .setImageDrawable(drawable);
} catch (FileNotFoundException e) {}
}
}
答案 1 :(得分:0)
试试这个..
ImageView receiptImage = (ImageView) findViewById(R.id.result_image);
Uri receiptUri = Uri.parse("/Kassenzettel/3.bmp");
InputStream inputStream = (InputStream)receiptUri.getContent();
Drawable drawable = Drawable.createFromStream(inputStream, null);
receiptImage .setImageDrawable(drawable);