如何检查imageview是否为空



我有一个有表单的应用程序,用户应该填写一些字段,我想禁用按钮"下一步",直到用户填写这些字段。

字段为:(iamgeView、EditText、Spinner..)

我知道如何检查文本编辑,但我如何检查用户是否填充了图像和微调器(图像视图将允许用户从本地库中选择图像)

我想要的是:如何检查用户是否填充了图像和微调器?这是我检查编辑文本的代码

  private boolean checkEditText2(EditText edit) {
    return edit.getText().length() == 0;
}

在xml文件中,您的图像没有android:src=""android:backgroud=""

   if(null!=imgView.getDrawable())
     {
        //imageview has image
     }else{
       //imageview has no image  
     }

不管接受的答案是什么,您都应该执行以下操作:

publie static boolean hasNullOrEmptyDrawable(ImageView iv)
{
    Drawable drawable = iv.getDrawable();
    BitmapDrawable bitmapDrawable = drawable instanceof BitmapDrawable ? (BitmapDrawable)drawable : null;
    return bitmapDrawable == null || bitmapDrawable.getBitmap() == null;
}

请参阅我先前回答中的解释。

最新更新