How to clear AutoCompleteTextView with inputType = none

I need a dropdown menu in my UI. Following the instructions I found on material.io I used AutoCompleteTextView with inputType="none". I need to reset it on button press and show the placeholder again, but if I use setText("") it will show an empty choice, I want to actually clear the AutoCompleteTextView and show the placeholder again. How can I accomplish it?

Answers 1

  • Try with this

    In java :

     button.setOnClickListener(v->{
                autoCompleteTextView.setText(null);
                //autoCompleteTextView.setText("");// or you can use this
                autoCompleteTextView.setFocusable(false);
            });
    

    And this for Kotlin :

    button.setOnClickListener { v: View? ->
                autoCompleteTextView.setText(null)
                autoCompleteTextView.isFocusable = false
            }
    

Related Articles