3

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>
Ali Hasanzade
  • 151
  • 15
  • You can use autocomplete textview and implement over it and set threshold to 0. – Surender Kumar Mar 03 '15 at 16:39
  • i cannot override SearchAutoComplete class, because i am getting cast exception when i want to cast from SearchAutoComplete to my custom class, i don't know what should i do , i tested anything, – Ali Hasanzade Mar 03 '15 at 16:46
  • Check this may it help you - http://stackoverflow.com/questions/18868268/how-to-build-gmail-like-search-box-in-the-action-bar – Surender Kumar Mar 03 '15 at 16:52

1 Answers1

4

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);
Parinda Rajapaksha
  • 2,963
  • 1
  • 36
  • 40