I have a button to select a picture or take a picture from camera, what i want is when the imageview that i use to attached the picture has an image on it., show a message right away, without clicking a button.
What i do now is when you press on a button then it shows some hidden edittext that says "image uploaded" or something. I want to achive this but without clicking any button. I've had tried many other options but all of them use a button.
Any samples or ideas! Thanks in advance
bb.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
validacionImagen();
}
});
METHOD THAT VALIDATES WHETER THERE'S AN ATTACHED IMAGE:
public void validacionImagen(){
if(imageView.getDrawable()==null){
buttonChoose.setError("Sube una fotografía");
buttonChoose.setFocusable(true);
buttonChoose.setFocusableInTouchMode(true);
buttonChoose.requestFocus();
}else{
imagencargada.setVisibility(View.VISIBLE);
textoimagencargada.setVisibility(View.VISIBLE);
buttonChoose.setError(null);
}
}
PICTURE CODE:
private void showFileChooser() {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Elige una imagen"), PICK_IMAGE_REQUEST);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == CAM_REQUEST){
Bitmap bitmap = (Bitmap) data.getExtras().get("data");
filePath = data.getData();
try {
bitmap = MediaStore.Images.Media.getBitmap(getActivity().getContentResolver(), filePath);
imageView.setImageBitmap(bitmap);
} catch (IOException e) {
e.printStackTrace();
}
//imageView.setImageBitmap(bitmap);
}else if (requestCode == PICK_IMAGE_REQUEST && resultCode == Activity.RESULT_OK && data != null && data.getData() != null) {
filePath = data.getData();
try {
bitmap = MediaStore.Images.Media.getBitmap(getActivity().getContentResolver(), filePath);
imageView.setImageBitmap(bitmap);
} catch (IOException e) {
e.printStackTrace();
}
}
}