监听EditText内容变化

1、给EditText追加ChangedListener

EditText editText = (EditText) findViewById(R.id.edittext);

editText.addTextChangedListener(watcher);

 

 

 

2、描述监听

private TextWatcher watcher = new TextWatcher() {
    
    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {
        // TODO Auto-generated method stub
        
    }
    
    @Override
    public void beforeTextChanged(CharSequence s, int start, int count,
            int after) {
        // TODO Auto-generated method stub
        
    }
    
    @Override
    public void afterTextChanged(Editable s) {
        // TODO Auto-generated method stub
        
    }
};

你可能感兴趣的:(EditText)