[英]How can i check if imageview is empty or not
i have an application that has form and there is some fields the user should fill it ,i want to put the button "Next" disable until the user fill this fields.我有一个具有表单的应用程序,并且有一些字段需要用户填写,我想禁用“下一步”按钮,直到用户填写这些字段。
the fields is:(iamgeView, EditText,Spinner..)字段是:(iamgeView, EditText,Spinner..)
i know how to check the text Edit but how can i check if the user fill the image and spinner or not (image view will let the user choose an image from native gallery)我知道如何检查文本编辑但我如何检查用户是否填充了图像和微调器(图像视图将让用户从本机图库中选择图像)
What i want: how can i check if the user fill the image and spinner or not?我想要什么:我如何检查用户是否填充了图像和微调器? this is my code to check the Edit Text
这是我检查编辑文本的代码
private boolean checkEditText2(EditText edit) {
return edit.getText().length() == 0;
}
In xml file your image have not android:src=""
and android:backgroud=""
在 xml 文件中,您的图像没有
android:src=""
和android:backgroud=""
if(null!=imgView.getDrawable())
{
//imageview has image
}else{
//imageview has no image
}
Despite what the accepted answer proposes, you should do the following instead:尽管已接受的答案提出了建议,但您应该执行以下操作:
publie static boolean hasNullOrEmptyDrawable(ImageView iv)
{
Drawable drawable = iv.getDrawable();
BitmapDrawable bitmapDrawable = drawable instanceof BitmapDrawable ? (BitmapDrawable)drawable : null;
return bitmapDrawable == null || bitmapDrawable.getBitmap() == null;
}
See explanation in my previous answer .请参阅我之前的回答中的解释。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.