Reputation: 221
I Have a form with 3 activities in my application. The user shouldn't go into the 2nd activity if he didn't complete filling-in the fields in 1st activity, the NextButton is kept disabled until the fields are complete.
The form contains: picture, edit text and a spinner..
Questions:
1-I created a function that checks whether the spinner and edittext has a value or not... but I didn't know where I should call this function...
2- How can I check if the imageview has contains a picture or not? note: the user will take the picture from the Gallery ..
-----------My Code ------------
// 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;
}
Upvotes: 1
Views: 1358
Reputation: 24181
about the checking the ImageView
, when you set the bitmap to your imageView
, try to set a Tag
to your ImageView
like this :
imgView.setTag(myBitmap);
and when you will try to check if there is an image or not , you will just get the tag and test if it's not null :
Bitmap b = (Bitmap) imgView.getTag();
if(b == null ) {
//the imageView is empty
}
else {
// there is an image
}
Upvotes: 1