I am using SearchView in android , i setting an adapter to search view, but suggestion popup box showing after one character, because i set Threshold on 1 ( it is not accept number less than 1 ), how can i set Threshold to Zero?
Like Google please, as you maybe know Google play does not have Threshold on application SearchView.
@Override
public void onCreateOptionsMenu(final Menu menu, MenuInflater inflater)
{
inflater.inflate(R.menu.main, menu);
searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
searchView.setOnQueryTextListener(this);
searchView.setOnSuggestionListener(this);
}
@Override
public boolean onQueryTextChange(final String arg0)
{
searchView.setSuggestionsAdapter(locationSearchAdapater);
}
searchable.xml
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/search_label"
android:hint="@string/search_hint"
android:voiceSearchMode="showVoiceSearchButton|launchRecognizer"
android:searchSuggestThreshold="1"
android:completionThreshold = "1" >
</searchable>
Use Appcompact activity with v7 Searchview and set threshold as follows,
AutoCompleteTextView searchAutoCompleteTextView = (AutoCompleteTextView) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);
searchAutoCompleteTextView.setThreshold(0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With