As I can assign a bitmap of a previously selected image, a ImageView an external Layout Dialog .. I have this code, which when not assign the layout to strip findViewById returns error, if assign it (which is what I think the problem is) simply nothing happens, not display the image.
Method that selects image gallery
public void selImagen(View v){
Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
int code = SELECT_PICTURE;
startActivityForResult(intent, code);
}
method that creates a bitmap image selected and displayed on a imageview
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//The problem is here I think, if so OTHERWISE INDICATE THAT BELONGS TO THIS LAYOUT IMAGEVIEW
LayoutInflater li = LayoutInflater.from(this);
View prompt = li.inflate(R.layout.prod_new_modal, null);
Uri selectedImage = data.getData();
InputStream is;
try {
is = getContentResolver().openInputStream(selectedImage);
BufferedInputStream bis = new BufferedInputStream(is);
final Bitmap bitmap = BitmapFactory.decodeStream(bis);
ImageView imageview = (ImageView)findViewById(R.id.imgView);
imageview.setImageBitmap(bitmap);
} catch (FileNotFoundException e) {
} catch (IOException e) {
e.printStackTrace();
}
}
Aucun commentaire:
Enregistrer un commentaire