• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

Kotlin RecyclerView filter search

 
Ranch Hand
Posts: 179
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I create an interface with edittext "Search" and "recyclerview" below

I would like to search an item in the recycler view
In my adapter for recyclerview "ItemAdapter" I implement Filterable:

and I add the following code in my adapter :

In my Activity, I add the following code,
what should I add to doing search in recycler view
 
Rancher
Posts: 660
10
Android Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use textChangedListener on your search editText.
 
Maha Sakka
Ranch Hand
Posts: 179
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As follows, what should I put as code here ?
 
Randy Tong
Rancher
Posts: 660
10
Android Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you read  https://inducesmile.com/android-programming/how-to-filter-a-recyclerview-with-a-edittext-in-android/ ?

Call getFilter in onTextChanged.
 
Maha Sakka
Ranch Hand
Posts: 179
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I add the following code :
   
And this is the adapter code :

But, the filter didn't work up to now
 
Randy Tong
Rancher
Posts: 660
10
Android Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried debug? Did it goes to the else part?
 
Maha Sakka
Ranch Hand
Posts: 179
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that the problem is here

I tried the debug and it goes to the else part
 
Randy Tong
Rancher
Posts: 660
10
Android Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any exceptions?
What you want to do with this line?
 
Maha Sakka
Ranch Hand
Posts: 179
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I remove this ligne :

The recycleview not be updated, always display all the government without filtre

 
Maha Sakka
Ranch Hand
Posts: 179
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I haven't found a solution so far, could you help me please
 
Randy Tong
Rancher
Posts: 660
10
Android Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wish too.

Is it possible for you to upload your project to git so I can help?
 
Don't listen to Steve. Just read this tiny ad:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic