4

I am looking for a way of filtering my data in a RecyclerView using a searchView but am still stuck. I read this post Filtering a recyclerview with a firebaserecycleradapter and Filter data on firebase using Searchview, but there is no any clear answer. And they are the only posts available.

There are also no clear examples on this issue. I am looking for a full simple example on Filtering data in a RecyclerView with Firebase using SearchView.

Below is Load() method ic all it in OnCreate() to load the list of Items.

 void Load(){
        //   mAuth.addAuthStateListener(mAuthLitsener);

        FirebaseRecyclerAdapter<Event,EventViewHolder> firebaseRecyclerAdapter_ = new FirebaseRecyclerAdapter<Event, GraduationListActivity.EventViewHolder>(Event.class,
                R.layout.item_event_view,
                GraduationListActivity.EventViewHolder.class,
                queryRef) {
            @Override
            protected void populateViewHolder(GraduationListActivity.EventViewHolder viewHolder, final Event model, final int position) {
                final String key_post = getRef(position).getKey();
                viewHolder.setEventLocation(model.getEventLocation());
                viewHolder.setEventName(model.getEventName());
                viewHolder.setEventType(model.getEventType());
                viewHolder.setEventDate(model.getEventDate());
                viewHolder.setEventPic(c, model.getEventImage());
                viewHolder.mView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        // Toast.makeText(EventViewActivity.this,"This is : "+position,Toast.LENGTH_LONG).show();

                        Intent loadMainActivity = new Intent(GraduationListActivity.this,BlogActivity.class);
                        loadMainActivity.putExtra("PARTY_NAME", model.getEventName());
                        startActivity(loadMainActivity);
                    }
                });
            }
        };

        mRecyclerview_event_view.setAdapter(firebaseRecyclerAdapter_);
    }

and this is my onCreateOptionsMenu()

 @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater menuInflater = getMenuInflater();
        menuInflater.inflate(R.menu.search, menu);

        SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.action_search));

        searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
            @Override
            public boolean onQueryTextSubmit(String query) {
                return false;
                // ????????
            }

            @Override
            public boolean onQueryTextChange(String newText) {
                //??????
                return true;
            }
        });

        return super.onCreateOptionsMenu(menu);
    }

So am using a searchView to search but am confused: what should I put in onQueryTextChange() and onQueryTextSubmit() according to Firebase?

halfer
  • 19,824
  • 17
  • 99
  • 186
Lutaaya Huzaifah Idris
  • 3,596
  • 8
  • 38
  • 77

0 Answers0