Search code examples
androidsearchview

SearchView in android Shows nothing in the list


This code is not working properly. Whenever i search for an item starts with a capital letter it shows nothing in the list. It only shows letters starting with small alphabets.

@Override
    public boolean onQueryTextChange(String s) {
        String userinput= s.toLowerCase();
        List<MultipleFoodWraper> newlist = new ArrayList<>();
        for(MultipleFoodWraper name :multipleFoodWraperArrayList) {
            if (name.getName().toString().contains(userinput)) {
                newlist.add(name);
            }

            adapter.updatelist(newlist);
        }
        return true;
    }

Solution

  • Converting name to lowercase does the trick name.getName().toString().toLowerCase().contains(userinput)