我有一個應用程序,其中有一個按鈕,從圖庫中的照片,並能正常工作,並選擇圖像後,我的應用程序節目又重新回到了活動並顯示圖像中的圖像視圖。採摘從畫廊和展示照片的圖像視圖
每一個工作正常,但有時,當我選擇一些特定的圖像預覽沒有顯示。我也曾嘗試仍壓縮圖像它不工作
我的代碼如下.. 在onCreate()
galeryBtn=(Button)findViewById(R.id.buttonGallery);
galeryBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, RESULT_LOAD_IMAGE);
}
});
在onActivityResult(INT requestCode,INT resultCode爲,意圖數據)
if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) {
Uri selectedImage = data.getData();
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver().query(selectedImage,filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
cursor.close();
// String picturePath contains the path of selected Image
// Show the Selected Image on ImageView
ImageView imageView = (ImageView) findViewById(R.id.imgView);
imageView.setImageBitmap(BitmapFactory.decodeFile(picturePath));
}
謝謝妳,還是工作我已經在不同的手機 – Biplab
測試我已經測試了,但是當我從電話給它toest選擇一些圖片「文件未找到」 – Biplab
你選擇高亮圖像?是這樣的,檢查出dev_get_content分支,看看它是否工作。 –