TextWatcher events are being fired multiple times

后端 未结 7 2104
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-05 12:57

I have an annoying problem with TextWatcher. i\'ve been searching the web but couldnt find anything. appreciate if someone could assist me.

For some reason t

相关标签:
7条回答
  • 2020-12-05 13:40
    boolean isOnTextChanged = false;
    
    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {
    }
    
    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {
        isOnTextChanged = true;
    }
    
    @Override
    public void afterTextChanged(Editable quantity) {
        if (isOnTextChanged) {
            isOnTextChanged = false;
           //dosomething
        }
    
    0 讨论(0)
提交回复
热议问题