我有一個帶有位圖圖片的imageview。我在onActivityResault中設置了這張照片。問題是當我改變肖像/風景的圖像disapears。更改爲縱向/橫向時,ImageView消失
protected void onActivityResult(int requestCode,int resultCode, Intent imageReturnedIntent) {
super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
switch(requestCode) {
case 1:
if(resultCode == RESULT_OK){
Uri selectedImage = imageReturnedIntent.getData();
InputStream imageStream;
try {
imageStream = getContentResolver().openInputStream(selectedImage);
Bitmap yourSelectedImage = BitmapFactory.decodeStream(imageStream);
image.setImageBitmap(yourSelectedImage);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
謝謝,但你能解釋這一點嗎? 我在我的活動中有一個位圖對象,我如何在這些方法上再次將圖像視圖圖片設置爲該位圖? – Yuval
我編輯了我的答案。 – piotrpo