简体   繁体   中英

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..)

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=""

   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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM