How to get text from AutoCompleteTextView?

前端 未结 9 1748
青春惊慌失措
青春惊慌失措 2020-12-05 04:25

I have an AutoCompleteTextView in my app which works. I have successfully created an onClickItemListener. The question is how to grab the text the

9条回答
  •  情歌与酒
    2020-12-05 04:57

    I think what you are looking for is this.

    String s = this.mCountry.getEditableText().toString();
    

    Where mCountry is the AutoCompleteTextView.

    this.mCountry = (AutoCompleteTextView) findViewById(R.id.autocomplete_country);
        ArrayAdapter adapterCountry = new ArrayAdapter(this, R.layout.list_item, countries);
        this.mCountry.setAdapter(adapterCountry);
    

    mCountry is the list of countries, and I wanted to save the country selected in SharedPreferences.

    Hope this helps.

提交回复
热议问题