In continuation of this post (Check String is NULL or EMPTY), I managed to successfully write up the if and else logic.
However, my third logic does not work. My third logic is something like checking both empty fields at the same time and if they are empty, the error icon would pop out.
Below are my codes:
private Boolean checkEmptyField(){
Boolean result = false;
String subject = querySubject.getText().toString();
String message = queryText.getText().toString();
if(subject.isEmpty()){
Toast.makeText(this, "Subject/Type field must not be blank!", Toast.LENGTH_SHORT).show();
querySubjectInfoIcon.setVisibility(View.VISIBLE);
}else if(message.isEmpty()){
Toast.makeText(this, "Content field must not be blank!", Toast.LENGTH_SHORT).show();
newQueryInfoIcon.setVisibility(View.VISIBLE);
}else if(subject.isEmpty() && message.isEmpty()){
Toast.makeText(this, "Fields are mandatory & must not be blank!", Toast.LENGTH_SHORT).show();
newQueryInfoIcon.setVisibility(View.VISIBLE);
querySubjectInfoIcon.setVisibility(View.VISIBLE);
}
else{
result = true;
}
return result;
}
When I run the app and intentionally leave two fields empty, it only checks and display the icon error on one field which is the subject field. This means only one logic (the if subject.isEmpty) is running.
As such I need some advises how I can run the third logic successfully. Thank you.