0
Explanation:
I have a common application where there are several components EditText
, where I assign them an Handler that would be this one:
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 is working ok, and the Debugger enters right, events are triggered, but I would like to have access to View that is firing the events to have access to the method .setText()
.
Question:
How to access the View
that triggered an Handler event TextWatcher
?
But I must change the
s
how?s = "aa"
?– Paulo Roberto Rosa
Yes. Internally the Textview class uses a
Editable
(or something I inherit fromEditable
) to store its value. This is passed to the methodafterTextChanged
. When you invokegetText
what returns is aEditable
– ramaral