![](/img/trans.png)
[英]How To Check if all ImageView inside GridLayout is not Empty?
[英]How can i check if imageview is empty or not
我有一個具有表單的應用程序,並且有一些字段需要用戶填寫,我想禁用“下一步”按鈕,直到用戶填寫這些字段。
字段是:(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;
}
請參閱我之前的回答中的解釋。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.