Is there any simple way to set a 2 TextView dropdown to an AutoCompleteTextView.
There is android.R.layout.two_line_list_item
Which I couldn\'t find any exa
Here's an extension for AutoCompleteTextView, Kotlin
fun AutoCompleteTextView.showListDropDown(list: List, action:(item: Any) -> Unit){
val adapter = ArrayAdapter(
this.context,
R.layout.custom_dropdown_item,
ArrayList(list)
)
this.setAdapter(adapter)
this.threshold = 1
this.onItemClickListener = AdapterView.OnItemClickListener { parent, view, position, id ->
val item = adapter.getItem(position)!!
action(item)
}
this.setOnTouchListener { _: View?, _: MotionEvent? ->
if (list.isNotEmpty()) {
if (this.text.toString() != "") adapter.filter
.filter(null)
this.showDropDown()
}
return@setOnTouchListener true
}
}