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

前端 未结 17 1984
终归单人心
终归单人心 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 16:14

    I too faced a scenario and I resolved in this way.

    1. Store the values that you want to show, in a static way (Ex.POJO).
    2. Check whether the stored static variable is not null and not empty.
    3. if, its not empty / not null / its length greater than 0, set dismissDropDown() for that autocompleteTextView.

    Please find the below snippet

    if(null != testText && testText.length() != 0) {
        mAutoCompleteSearch.setText(incomingActivity.toString());
        mAutoCompleteSearch.dismissDropDown(); //Dismiss the drop down
        } else {
        mAutoCompleteSearchDocketActivity.setText("");
                // Here it(drop down) will be shown automatically
        }
    

    Hope, this would help for someone, Cheers !

提交回复
热议问题