Practical No 8
Practical No 8
#JAVA_FILE
package com.example.practicalno8;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import androidx.appcompat.app.AppCompatActivity;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Optional: Set the threshold for how many characters to type before suggestions show
autoCompleteTextView.setThreshold(1); // Default is 2, set to 1 for quicker suggestions.
}
}
#xml_file
<AutoCompleteTextView
android:id="@+id/autoCompleteTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:hint="Type to search"
android:layout_marginTop="200dp" />
</RelativeLayout>