Activity_Main.
xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Name Of Student" />
<AutoCompleteTextView
android:id="@+id/autoCompleteTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="AutoCompleteTextView" />
</LinearLayout>
strings.xml
<resources>
<string name="app_name">Autocompletetextview</string>
<string-array name="studlist">
<item>Vaishani</item>
<item>komal</item>
<item>varsha</item>
<item>kiran</item>
<item>pooja</item>
<item>priya</item>
</string-array>
</resources>
MainActivity.java
package com.example.autocompletetextview;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
public class MainActivity extends AppCompatActivity {
String[] p;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
p=getResources().getStringArray(R.array.studlist);
AutoCompleteTextView s1=findViewById(R.id.autoCompleteTextView);
ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item,p);
s1.setThreshold(3);
s1.setAdapter(adapter);
}
}