简体   繁体   English

如何判断ImageView在android中是否有设置图像?

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

In android, if you create an imageview in the xml code like this: 在android中,如果你在xml代码中创建一个imageview,如下所示:

<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? 你怎么能在java代码中告诉它是否有设置图像?

There is another button that sets an image using the setImageBitmap function. 还有另一个按钮使用setImageBitmap函数设置图像。 So I want to tell if it has an image or not. 所以我想告诉它是否有图像。

Thanks 谢谢

pictureavatar.getDrawable() == null

如果为真,那么没有图像,否则它有图像

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Android中将图像从可绘制图像设置为ImageView - How to set image from drawable into imageview in Android 如果我的 imageview 有特定图像,如何检查 android 工作室? - How to check in android studio if my imageview has a specific image or not? 如何在ImageView中设置图像而不在android中全屏显示 - how to set the Image in ImageView without strected with full screen in android 如何在 Android 中从 Java 图像数据类型中设置 ImageView 资源 - How to set ImageView Resource from Java Image data type in Android 当Android中imageview具有width和height值时,如何将textview和imageview合并为图像复合? - How to combine textview and imageview into image compound when imageview has width and height values in android? 如何在imageview上设置捕获的图像 - how to set captured image on imageview android studio如果imageview没有图像,则使imageview下面的textView可见 - android studio Make a textView below an imageview visible if imageview has no image 如何检查imageview中是否有图像,并跳过该图像到下一个imageview - How to check if an imageview has an image in it and skip over the image to the next imageview Android-将图片设置为imageview作为用户个人资料 - Android - set image to imageview for user profile 如何检查 imageview 是否具有特定类型的图像 - How to check if an imageview has a specific type of image
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM