How to find out if an Imageview has an informed photo

Asked

Viewed 496 times

2

Hello, I want to create a condition that checks whether all the fields on the screen were informed by the user or not. If any have not been informed, I would like to present a Toast showing error. The problem is that on this screen I own an Imageview and I can’t find out when it was informed or not.

Code for this function:

if ((edtTitulo.getText().toString().isEmpty()) ||   (edtPreparo.getText().toString().isEmpty()) || (edtIngredientes.getText().toString().isEmpty())){
    Toast toast = Toast.makeText(getApplicationContext(), "Todos os campos são obrigatórios", Toast.LENGTH_LONG);
    toast.show();
}

How to add empty Imageview in this condition?

  • That’s right @Andersonsantos I implemented a method that allows the user to select an image from the gallery and wanted to know if he filled this field

1 answer

3


Depending on the method you used to assign the photo to Imageview use

if(imageView.getDrawable() != null)

or

if(imageView.getBackground() != null)
  • The first option worked perfectly. Thank you very much

Browser other questions tagged

You are not signed in. Login or sign up in order to post.