How to disable AutoCompleteTextView's drop-down from showing up?

前端 未结 17 2010
终归单人心
终归单人心 2020-12-05 15:30

I use the following code to set text to an AutoCompleteTextView field. But I noticed that when I set certain text (not all text, but some) to it, it will automatically pop u

17条回答
  •  渐次进展
    2020-12-05 15:52

    I have solved the same problem with this code:

    contacts_search.addTextChangedListener(new TextWatcher() {
    
                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {
                    // TODO Auto-generated method stub
                    contacts_search.dismissDropDown();      
                }
    
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count,
                        int after) {
                    // TODO Auto-generated method stub
                    contacts_search.dismissDropDown();
                }
    
                @Override
                public void afterTextChanged(Editable s) {
                    // TODO Auto-generated method stub
                    contacts_search.dismissDropDown();
                }
            });
    

    Here, contacts_search is my AutoCompleteTextView

提交回复
热议问题