I have validation for editText. If the editText field is empty it should fail validation and stop the user moving on to another Activity,
editText
Activity
You can also try this:
if ( ( userName.getText().toString().trim().equals("")) ) { Toast.makeText(getApplicationContext(), "User name is empty", Toast.LENGTH_SHORT).show(); } else { Intent i = new Intent(getApplicationContext(), Login.class); startActivity(i); }