How to avoid getting both called: onItemClicked and onTextChanged on AutoCompleteTextView

大兔子大兔子 提交于 2019-12-03 00:05:47

isPerformingCompletion() was added in API Level 3. It returns true after an item has been selected from the drop-down list and TextWatcher listeners are about to be triggered. In short, to avoid the behaviour described:

public void onTextChanged(CharSequence s, int start, int before, int count) {
    if (autoCompleteView.isPerformingCompletion()) {
        // An item has been selected from the list. Ignore.
        return;
    }

    // Your code for a general case
}

There is no particular solution for this problem.I will suggest that you should put code on which is in inside onclicklistener() in the begining of textchangedlistener() so that the code that u want to get execute first will execute first then the code that you want to get execute last will execute last.Hope this will help you.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!