Here is my code hope it is clear enough With this code i am trying to use the isEnabled function to check if my EditText fields have values, if they don't have values the submit Button must be disabled else if they all have values the button must enable so the user can navigate to new activity
public class RegisterAccountActivity extends AppCompatActivity {
//Declaring Button and EditText
private Button submit;
private EditText name;
private EditText surname;
private EditText email;
private EditText phoneNumber;
private EditText address;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register_account);
submit = (Button) findViewById(R.id.btnSubmitPersonalDetails);
name = (EditText)findViewById(R.id.edtName);
surname = (EditText)findViewById(R.id.edtSurname);
email = (EditText)findViewById(R.id.edtEmail);
phoneNumber = (EditText)findViewById(R.id.edtPhoneNumber);
address = (EditText)[findViewById][1](R.id.edtPostalAddress);
//Calling the checking fields method
checkFields();
}
//Function to disable button if fields doesn't have value
public void checkFields() {
//Here i am checking if EditText have values
if (!submit.getText().toString().isEmpty() &&
!name.getText().toString().isEmpty() &&
!surname.getText().toString().isEmpty() &&
!email.getText().toString().isEmpty() &&
!phoneNumber.getText().toString().isEmpty() &&
!address.getText().toString().isEmpty()) {
submit.setEnabled(true);
} else {
submit.setEnabled(false);
}
}
[Find attached image for the form]