activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/autocom">
</AutoCompleteTextView>
</LinearLayout>
MainActivity.kt
package com.androinidan.myapplication
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.AdapterView
import android.widget.ArrayAdapter
import android.widget.AutoCompleteTextView
import android.widget.Spinner
import android.widget.Toast
class MainActivity : AppCompatActivity() {
var studentdata= arrayOf("Ashih","Swathi","Anuj","Raj", "Ashih","Swathi","Anuj","Raj",
"Ashih","Swathi","Anuj","Raj", "Ashih","Swathi","Anuj","Raj","Ashih","Swathi","Anuj","Raj","451536234")
var auto: AutoCompleteTextView?=null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.main)
auto = findViewById(R.id.autocom)
val adapter: ArrayAdapter<String> = ArrayAdapter<String>(this,
android.R.layout.select_dialog_item, studentdata)
auto!!.threshold = 1
auto!!.setAdapter(adapter)
}
}