You put this check in the onCreate() method so that it onCreate() only once, at the beginning. You need to create a TextWatcher for EditTexts :
TextWatcher tw = new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) {} @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {} @Override public void afterTextChanged(final Editable s) { if(t1.getText().toString().equals("e") && t2.getText().toString().equals("123") ){ b2.setEnabled(true); b2.setText("ON"); } } }); t1.addTextChangedListener(tw); t2.addTextChangedListener(tw);
Thus, every time someone changes the text in one of these EditText s, the condition is checked.
Of course, you can think of something more effective, for example, creating an accept button, and when you click, the condition is checked. But it is up to you.
source share