InnoFang
EditText有一个addTextChangedListener的监听事件mEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
Log.i(TAG, s.length() + "");
// 当EditText的内容长度超过10时,按钮可点击,否则不可点击
if (s.length() > 10){
mButton.setClickable(true);
mButton.setText("可点击");
} else {
mButton.setClickable(false);
mButton.setText("不可点击");
}
}
@Override
public void afterTextChanged(Editable s) {
}
});