0

In this solution (How to filter the data in realm adapter?) query handles only when i press enter. Proviso: i use RealmRecyclerViewAdapter instead of RealmBaseAdapter.

How to implement live search?

Dereva
  • 23
  • 1
  • 6
  • Do the same thing as in that example except use a `TextWatcher` for the edit text. Or at least that's what I typically did, except I used ButterKnife and `@OnTextChanged(R.id.edit_text)`. Calling `updateData()` with the new query is what you need – EpicPandaForce Jan 03 '18 at 20:41
  • @EpicPandaForce Did I understand correctly that `onQueryTextChange` doesn't provide possibility to live search so i need to make text in `SearchView` as `EditText`, and then apply `addTextChangedListener(new TextWatcher())`? In this case i didn't savvied what to do in overridden methods of TextWatcher. Can you explain it in more simple terms? I'm new to android development and for now i try not to use any libraries such a butterknife just to get used to original java logic. – Dereva Jan 04 '18 at 09:57
  • Well I'm not sure if SearchView is "unable to provide it", but it didn't work that well for me, so yeah, I tend to use EditText+TextWatcher. – EpicPandaForce Jan 04 '18 at 10:32
  • @EpicPandaForce I was completely inconsiderated. In that example i've just change body of `onQueryTextChange` to `adapter.getFilter().filter(newText)`; Works for now. `TextWatcher` wasn't needed, but I learned for myself a new. Thanks for response! – Dereva Jan 04 '18 at 12:07

0 Answers0