0

When I search something it updates recycler view accordingly and onQueryTextChange method I am showing layout No items found if it doesn't matches, it is showing No items found when I enter 3rd character and if first two character doesn't match then it shows blank screen.

I want it to show No items found even if first two characters doesn't match.

@Override
        public boolean onQueryTextChange(String query) {
            newsListAdapter.getFilter().filter(query);
            if (newsListAdapter.getItemCount() < 1) {
                listRecyclerView.setVisibility(View.GONE);
                noRecord.setVisibility(View.VISIBLE);
            } else {
                listRecyclerView.setVisibility(View.VISIBLE);
                noRecord.setVisibility(View.GONE);
            }
            return false;
        }
Ubaid Tanoli
  • 183
  • 14

2 Answers2

0

if your are using search view check this link Android search list while typing,

if you use autocompletetextview you can set the throushouldvalue

Archu Mohan
  • 199
  • 1
  • 5
  • 14
  • throushouldvalue is not a thing. Also, linking to other posts is discouraged since links can be deleted anytime. Just copy the relevant parts here. – Zun Sep 14 '18 at 08:03
  • SearchView.SearchAutoComplete mSearchSrcTextView = (SearchView.SearchAutoComplete) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text); // show results from 1 char mSearchSrcTextView.setThreshold(1 OR 2); – Archu Mohan Sep 14 '18 at 08:14
  • Yeah it's great that you know the code but edit your original comment. – Zun Sep 14 '18 at 08:15
0

For AutoCompleteTextView use this:

AutoCompleteTextView searchAutoCompleteTextView = (AutoCompleteTextView) mSearchView.findViewById(getResources().getIdentifier("search_src_text", "id", getPackageName()));
searchAutoCompleteTextView.setThreshold(1);

The threshold value defines, how much characters you need to type in, until the first proposal can be shown (listeners get called).

Thomas Richter
  • 833
  • 8
  • 20