0

I want to use TextWatcher(textChangelistener) for a TextView in android I made a study on that there I came to know that, it is possible to have OnTextChangeListener for EditText only. But my TextView will automatically change according to the changes in the someother EditTexts. so I want to have a OnTextChangedListener to proceed with further calculations..

can anyone help me doing this!!!!! Thanks in Advance

N Dorigatti
  • 3,482
  • 2
  • 22
  • 33
lakshmi
  • 21
  • 3
  • 9

1 Answers1

0

As far as I understood your question EditText's text is changed by user dynamically so we need TextWatcher for EditText, but in case of TextView whatever text is being changed will be changed by developer only. So you should perform operations on it whenever you are setting text to TextView. Still if you want to use that use it as follows.

textView.addTextChangedListener(new TextWatcher() {

    boolean editing=false;

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {

    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count,int after) {

    }

    @Override
    public void afterTextChanged(Editable s) {
        if (!editing){
           editing=true;
           s.append("A");
           editing=false;
    }


    }
});
Nikhil
  • 3,711
  • 8
  • 32
  • 43