romasha ali

romasha ali

  • 1.9k
  • 94
  • 32.2k

selected image not showing in imageview

Jan 4 2018 6:18 AM
i set breakpoint but could not get the problem.. Could you please sort this out..I need to submit my project tonight..
 
MY COde:
 
Button buttonLoadImage = (Button) findViewById(R.id.button4);
buttonLoadImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
{
Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, Selected_image);
}
});
}
protected void onActivityResult(int requestCode, int resultCode , Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == Selected_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();
ImageView imageView = (ImageView) findViewById(R.id.image_view);
imageView.setImageBitmap(BitmapFactory.decodeFile(picturePath));
}
}

Answers (2)