AutoCompleteTextView item selection programmatically

前端 未结 9 2054
故里飘歌
故里飘歌 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 15:02

    I figure out after dig into the AutoCompleteTextView code on android source code:

    fun AutoCompleteTextView.selectItem(text: String, position: Int = 0) {
      this.setText(text)
      this.showDropDown()
      this.setSelection(position)
      this.listSelection = position
      this.performCompletion()
    }
    

提交回复
热议问题