如何判断的ImageView android系统中有一组形象? [英] How to tell if ImageView has a set image in android?

查看:140
本文介绍了如何判断的ImageView android系统中有一组形象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android上,如果你在XML code这样创建的ImageView:

 < ImageView的
    机器人:ID =@ + ID / picture_avatar
    机器人:layout_width =90dp
    机器人:layout_height =110dp
    机器人:背景=#bdbdbd/>

你怎么能在java code说,如果有一组形象?

还有一个按钮,它将使用 setImageBitmap 功能的图像。所以,我想告诉它是否有一个图像或没有。

感谢


解决方案

  pictureavatar.getDrawable()== NULL

如果属实,那么没有图像否则它具有图像

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

解决方案

pictureavatar.getDrawable() == null

If true, then no image else it has an image

这篇关于如何判断的ImageView android系统中有一组形象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆