-1

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;
    }
3
  • 1
    I don't know where the name variable gets initialized with value or what it holds, but shouldn't this, s.toLowerCase(); be the main cause of your issue? Commented Jan 3, 2019 at 21:51
  • Have you tried name.getName().toString().toLowerCase() when comparing? Commented Jan 3, 2019 at 21:59
  • @LeoPelozo Thanku so so much it works 👍🏼 Commented Jan 3, 2019 at 22:04

1 Answer 1

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.