How To perform Search Operation in Android Studio :
How To perform Search Operation in Android Studio :
Xml file :
<AutoCompleteTextView
android:id="@+id/auto"
android:layout_width="151dp"
android:layout_height="48dp"
android:hint="search"
android:textSize="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.857"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.111" />
android:id="@+id/auto"
android:layout_width="151dp"
android:layout_height="48dp"
android:hint="search"
android:textSize="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.857"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.111" />
That AutoCompleteTextView Tag is More Useful for Search Operation perform. because if you can type some product it should fetch from the list at suggestion list
Then We will See about the Java Page
Java File:
name = new ArrayList<String>();
name.add("Welcome");
name.add("to");
name.add("india");
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,name);
I use ArrayAdapter that ArrayAdapter is more use for the Suggestion list bacause we can't directly define the list at AutoCompleteTextView , so i can use the ArrayAdapter and to add list value in to the ArrayAdapter the i can Assign the Array Adapter to the AutoCompleteTextView
at.setAdapter(arrayAdapter);
at.setThreshold(1);
find.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
t1.setText("Finded...");
}
});
}
}
at.setThreshold(1);
it use for how many letter you should enter after the suggestion list will should that
Comments
Post a Comment