How do I access the View that triggered one of the events in a TextWatcher?

0

Explanation:

I have a common application where there are several components EditText , where I assign them a handler that would be this here:

TextWatcher handler = 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) {
        oldText = s.toString();
    }

    @Override
    public void afterTextChanged(Editable s) {
        //v.setText("afterTextChanged");
    }
};

It's working okay, and the debugger goes in right, the events are triggered, however I'd like to have access to View which is triggering the events to gain access to the .setText() method.

Question:

How do I access the View that triggered a handler event TextWatcher ?

Exactly the same as v of the onClick event

    
asked by anonymous 04.04.2014 / 16:58

1 answer

2

What you are looking for is the value s passed to the function. If you change s the TextView will show this change.

Note that any changes you make to s , the afterTextChanged method will be called again, which will cause an infinite loop .

Source TextWatcher

    
04.04.2014 / 17:06