How can I detect whether or not an Image View has a picture in it upon a button click. I had a class that displays a picture and some results, but I don’t want the user to be able to access those results (pushing the button) until the results have been written to that class.
So, I figured I needed to check to see if there was a picture displayed in the ImageView yet.
So something like:
case R.id.previous_box:
if (R.id.photoResultView == null){
//throw up a dialog box saying they need to snap a pic first.
}
Intent j = new Intent(DTF.this, Result.class);
startActivity(j);
return;
but obviouslt R.id.photoResultView == null isn’t the right way to do it…anyone know how?
Tanks!
EDIT: Line 184
if (photoResultView.getDrawable() == null) {
EDIT:
case R.id.previous_box:
if (photoResultView.getDrawable() == null) {
showToast(DTF.this, "You have to take a picture first");
return;
}
Intent j = new Intent(main.this, Result.class);
startActivity(j);
return;
Try, instead of the
ifblock you currently have, this:ImageView.getDrawable()returns either a Drawable or null (if there is no Drawable set).Basically, say you have something like this: