I want to make it impossible for the user to click on a button until he does not 'get out of' or clicks away from an EditText.
Like, the button will be there, but when the user goes to enter text in an EditText, it will be grayed out, and will be clickable again only when the user leaves the editText.
I hope my question is clear. How can I do this?
Your button behaviour depends on the focus of the editext so you can use
mEditText.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
mButton.setEnabled(false)
} else {
mButton.setEnabled(true)
}
}
});
the if is extended, consider that you can solve in just one line
mButton.setEnabled(!hasFocus)