views:

218

answers:

1

I have 2 EditText01 and 02. My button will be disable once the activity is started. And when these two EditText box got text inside, the button have to be enabled back. However my button is always disable and can't enable back using, button.setEnabled(true);.

Can anyone help me with this? Thx... :)

summit.setEnabled(false);

buttonEnable();

public void buttonEnable(){
    if (feedback.length()>0 && email.length()>0){
        summit.setEnabled(true);
    }else{
        summit.setEnabled(false);
    }
}
A: 

You're correct about needing a TextWatcher. The afterTextChanged(Editable) method is the one you're interested in for something like this. Call your buttonEnable() method from it, and add the TextWatcher to any applicable text fields. (Looks like feedback and email from your sample.)

adamp