omega
omega

Reputation: 43943

How to tell if ImageView has a set image in android?

In android, if you create an imageview in the xml code like this:

<ImageView
    android:id="@+id/picture_avatar"
    android:layout_width="90dp" 
    android:layout_height="110dp"
    android:background="#bdbdbd" />

How can you tell in the java code, if it has a set image?

There is another button that sets an image using the setImageBitmap function. So I want to tell if it has an image or not.

Thanks

Upvotes: 1

Views: 6830

Answers (1)

Vrashabh Irde
Vrashabh Irde

Reputation: 14377

pictureavatar.getDrawable() == null

If true, then no image else it has an image

Upvotes: 3

Related Questions