[英]Checking empty fields in android application
我的申請中有一個包含3個活動的表格。 如果用戶未完成在第一活動中填寫字段,則不應進入第二活動,NextButton將保持禁用狀態,直到填寫完為止。
表單包含:圖片,編輯文本和微調框。
問題:
1-我創建了一個檢查微調器和edittext是否具有值的函數...但是我不知道應該在哪里調用該函數...
2-如何查看imageview是否包含圖片? 注意:用戶將從圖庫中拍照。
-----------我的代碼------------
// For Disabling The Buttons
void updateButtonState() {
if(checkimg()&& CheckSpinner() && checkEditText2(CaseName) && checkEditText2(CaseAge) && CheckRButtons(RBMale, RBFemale) ) {
Nextb.setEnabled(true);}
else {Nextb.setEnabled(false);}
}
// For Spinner
private boolean CheckSpinner(){
boolean checkspiner=false;
if( strH == "0" && strM == "0")
checkspiner=false;
else checkspiner= true;
return checkspiner;
}
// For Buttons
private boolean CheckRButtons(RadioButton rBMale2, RadioButton rBFemale2) {
// TODO Auto-generated method stub
boolean but = false;
if ( RBMale.isChecked() || RBFemale.isChecked())
but = true;
return but;
}
// For EditText
private boolean checkEditText2(EditText edit) {
return edit.getText().length() != 0;
}
關於檢查ImageView
,將位圖設置為imageView
,請嘗試將Tag
設置為ImageView
如下所示:
imgView.setTag(myBitmap);
當您嘗試檢查是否有圖像時,您將只獲取標簽並測試其是否不為null:
Bitmap b = (Bitmap) imgView.getTag();
if(b == null ) {
//the imageView is empty
}
else {
// there is an image
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.