6

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;
}
user1257040
  • 119
  • 1
  • 2
  • 12
  • i suppose you save the image somewhere when you return from the gallery? – njzk2 Mar 14 '12 at 17:28
  • you mean this ? ` Uri selectedImageUri = data.getData(); CaPic.setImageURI(selectedImageUri);` – user1257040 Mar 14 '12 at 18:06
  • at some point, you were considering getting the image back to store it somewhere, weren't you ? can't you use the same method and check for null or something? – njzk2 Mar 15 '12 at 09:17

2 Answers2

11

In xml file your image have not android:src="" and android:backgroud=""

   if(null!=imgView.getDrawable())
     {
        //imageview has image
     }else{
       //imageview has no image  
     }
Samir Mangroliya
  • 39,918
  • 16
  • 117
  • 134
0

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.

Alexander Abakumov
  • 13,617
  • 16
  • 88
  • 129