Using Android AutoCompleteTextView with ArrayAdapter instead of ArrayAdapter

后端 未结 4 511
广开言路
广开言路 2020-12-23 17:51

I wanted to use AutoCompleteTextView in my android application.I know how to use it with simple array of Strings, but I wanted AutoCompleteTextView to use list of Objects t

4条回答
  •  醉酒成梦
    2020-12-23 18:21

    You can override getItem in this adapter, depend on each type to convert it into String

     override fun getItem(position: Int): String? {
            val item = listData[position]
            when (item) {
                is BankItem -> {
                    return item.bankName
                }
            ....
     }
    

提交回复
热议问题