0
當我按下加載按鈕,我想假設去廚房,選擇一張圖片,然後將imageview img設置爲該圖片。問題是我在廚房中選擇了一張照片後,imageview沒有更新。但是,如果我第二次按加載按鈕,則需要一兩秒鐘才能加載廚房,在此期間,imageview將加載我之前選擇的圖片。有人能幫助我,讓我能得到的ImageView刷新正確加載圖片後,imageview不更新
load.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), SELECT_PICTURE);
try {
FileInputStream in = new FileInputStream(selectedImagePath);
bMap = BitmapFactory.decodeStream(in);
img.setImageBitmap(bMap);
if (in != null) {
in.close();
}
img.invalidate();
} catch (Exception e) {}
}
});
謝謝,我把加載和設置位圖到我的活動結果後,它的工作 – help