0

I've searched numerous questions throughout stackoverflow but still I'm unable to get my answer. Nothing comes up when i begin typing with lower case alphabets in my searchview. I would like to be able to begin typing with upper case or lower case letter to be able to filter through my list of recycler card views. Also if i could filter it by typing any character that is found in a word without following the alphabet sequence of a particular word. Below is my onQueryTextChange

@Override
        public boolean onQueryTextChange(String newText) {




          Query search = mDatabaseReference.orderByChild("country").startAt(newText).endAt(newText+"\uf8ff");



            FirebaseRecyclerAdapter<CardItem, SearchViewHolder> firebaseRecyclerAdapter22
                    = new FirebaseRecyclerAdapter<CardItem, SearchViewHolder>(
                    CardItem.class,
                    R.layout.single_card,
                    SearchViewHolder.class,
                    search
            ) {
                @Override
                protected void populateViewHolder(final SearchViewHolder hiViewHolder, final CardItem model, int position) {

                    hiViewHolder.setPicture(model.getThumbPhoto() , getApplicationContext());
                    hiViewHolder.setTitle(model.getTitle());
                    hiViewHolder.setCountry(model.getCountry());
                    hiViewHolder.setPrice("Price: $" + model.getPricePerGuest());

                }

            };


            mTripList.setAdapter(firebaseRecyclerAdapter22);


            return false;
        }
    });

    return super.onCreateOptionsMenu(menu);
}

I've tried setting newText to lowerCase as follow but it causes me to not able to filter anything from my SearchView:

@Override
        public boolean onQueryTextChange(String newText) {

        newText = newText.toLowerCase();


        Query search = mDatabaseReference.orderByChild("country").startAt(newText).endAt(newText+"\uf8ff");



            FirebaseRecyclerAdapter<CardItem, SearchViewHolder> firebaseRecyclerAdapter22
                    = new FirebaseRecyclerAdapter<CardItem, SearchViewHolder>(
                    CardItem.class,
                    R.layout.single_card,
                    SearchViewHolder.class,
                    search
            ) {
                @Override
                protected void populateViewHolder(final SearchViewHolder hiViewHolder, final CardItem model, int position) {

                    hiViewHolder.setPicture(model.getThumbPhoto() , getApplicationContext());
                    hiViewHolder.setTitle(model.getTitle());
                    hiViewHolder.setCountry(model.getCountry());
                    hiViewHolder.setPrice("Price: $" + model.getPricePerGuest());

                }

            };


            mTripList.setAdapter(firebaseRecyclerAdapter22);


            return false;
        }
    });

    return super.onCreateOptionsMenu(menu);
}
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Hso Zote
  • 21
  • 8
  • Firebase Database queries are case sensitive. If you want to implement case-indifferent search, you should: 1) store an additional value that is always lowercase (or uppercase, it doesn't really matter), 2) change the search string to lowercase and use that for the search. – Frank van Puffelen Nov 08 '17 at 16:30
  • See https://stackoverflow.com/questions/37643459/case-insensitive-sorting-with-firebase-orderbychild, https://stackoverflow.com/questions/38590937/firebase-query-methods-startat-taking-case-sensitive-parameters, and https://stackoverflow.com/questions/38618953/how-to-do-a-simple-search-in-string-in-firebase-database/40633692 for some examples. – Frank van Puffelen Nov 08 '17 at 16:34
  • Thank You so much.. Could you reply as an answer instead of a comment so I could accept your answer? Thanks – Hso Zote Nov 08 '17 at 17:00
  • If these links helped, I'm going to close your question as a dupe. – Frank van Puffelen Nov 08 '17 at 17:07
  • Okay thank you so much – Hso Zote Nov 08 '17 at 17:12

0 Answers0