[英]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.