Skip to content Skip to sidebar Skip to footer

Checking Empty Textedit

I'm trying to program a simple register application, the user have to fill some fields, where some of them are obligatory. So, I need to check if the user write the info there. I'm

Solution 1:

I do this for checking empty EditText...

if (editTextName.getText().toString().equalsIgnoreCase("")) 
{
      // show message/toast for empty name
} 
else if (editTextSurname.getText().toString().equalsIgnoreCase("")) 
{
     // show message/toast for empty Surname
} 
else if (editTextEmail.getText().toString().equalsIgnoreCase(""))  
{
     // show message/toast for empty Email
}
else 
{
     // If above all conditions are false means all fields are not empty so put your action here 
}

Hope this help..

Solution 2:

I am not catch what you want. Below is what I had used

  • add below code to your requireFields
    privatestaticfinal SparseArray< RequireFields > _map=newSparseArray< RequireFields >();
    static {
        for (RequireFields cmd: RequireFields.values())
        {
            _map.put(cmd.position,cmd);
        }
    }
    publicstatic RequireFields valueOf(int value) { 
      RequireFieldsfield= _map.get(value);
      if (field==null) {
        Log.d("RequireFields","RequireFields position "+value+" not found");
      }
      return field; 
      }
    

  • then you can use switch like
    switch(RequireFields.valueOf(value){
        caseNAME:
            .......    // your handlerbreak;
        caseSURNAME:
            ....
    }
    

    Hope this help

  • Post a Comment for "Checking Empty Textedit"