You just need to create an else
for your if
, then move your call to startActivity()
into that like so:
// Expand this condiditional to perform whatever other validation you want
if( Name2.getText().toString().length() == 0 ) {
Name2.setError( "First name is required!" );
} else {
// Validation passed, show next Activity
Intent intent = new Intent(NewCard.this, Template.class);
startActivity(intent);
}