Reputation: 119
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;
}
Upvotes: 6
Views: 23425
Reputation: 40426
In xml file your image have not android:src=""
and android:backgroud=""
if(null!=imgView.getDrawable())
{
//imageview has image
}else{
//imageview has no image
}
Upvotes: 11
Reputation: 14579
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.
Upvotes: 0