AutoCompleteTextView item selection programmatically

前端 未结 9 2075
故里飘歌
故里飘歌 2021-02-18 14:41

I have an autocomplete text view that is filled with cities from an sqlite database that calls an async task on item click, recently I added an option to detect my location usin

9条回答
  •  鱼传尺愫
    2021-02-18 14:58

    Try with adding below after setText() in AutoCompleteTextview:-

    autoCompleteTV.setSelection(position);
    

    Updated:

    This will work in Spinner and AutoCompleteTextView which has dropdown feature, but it will not work with EditText.

    Here you can check docs for AbsSpinner in this link: https://developer.android.com/reference/android/widget/AbsSpinner.html#setSelection(int)

提交回复
热议问题