How to disable/enable button when the edit text is empty/nonempty
<p>I have 2 edit text and 1 button. How can I make this button to be disabled until the user fill all the edit text? I used this code but when I run this code it always disable the button even when I fill the 2 Edit text, also I do not know what the onTextChanged and beforeTextChanged doing!!</p>

<p>Please help me, I will appreciate it.</p>

<pre><code>public class TestActivity extends Activity {
/** Called when the activity is first created. */
EditText edit1;
EditText edit2;
EditText edit3;
Button button;
String test1;


@Override
protected void onCreate(Bundle savedInstanceState) {
    // Your initialization code...
    // TODO Auto-generated method stub
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);

            edit1= (EditText) findViewById(R.id.edit1);
            edit2= (EditText) findViewById(R.id.edit2);

            button=(Button) findViewById(R.id.button);




   TextWatcher watcher = new LocalTextWatcher();
    edit1.addTextChangedListener(watcher);
    edit2.addTextChangedListener(watcher);

    updateButtonState();
}

void updateButtonState() {
    boolean enabled;
    if(enabled = checkEditText(edit1)
        &amp;&amp; checkEditText(edit2)){
        button.setEnabled(enabled);}
        }
}

private boolean checkEditText(EditText edit) {
    return Integer.getInteger(edit1.getText().toString()) != null;
}

private class LocalTextWatcher implements TextWatcher {
    public void afterTextChanged(Editable s) {
        updateButtonState();
    }

    public void beforeTextChanged(CharSequence s, int start, int count, int after) {
    }

    public void onTextChanged(CharSequence s, int start, int before, int count) {
    }
}




}}}
</code></pre>
