You could unregister the watcher, and then re-register it.
To unregister the watcher use this code:
txt_qty.removeTextChangedListener(yourTextWatcher);
to re-register it use this code:
txt_qty.addTextChangedListener(yourTextWatcher);
Alternatively, you could set a flag so that your watcher knows when you have just changed the text yourself (and therefore should ignore it).
define one flag in your activity is:
boolean isSetInitialText = false;
and when you are calling txt_qty.settext(yourText) make isSetInitialText = true before calling set text,
And then update your watcher as:
txt_qty.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
if (isSetInitialText){
isSetInitialText = false;
} else{
// perform your operation
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (isSetInitialText){
isSetInitialText = false;
} else{
// perform your operation
}
}
@Override
public void afterTextChanged(Editable s) {
if (isSetInitialText){
isSetInitialText = false;
} else{
// perform your operation
}
}
});