Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Kotlin RecyclerView filter search

 
Ranch Hand
Posts: 165
1
  • Mark post as helpful
  • send pies
  • 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: 437
7
Android Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use textChangedListener on your search editText.
 
Maha Sakka
Ranch Hand
Posts: 165
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As follows, what should I put as code here ?
 
Randy Tong
Rancher
Posts: 437
7
Android Tomcat Server Java
  • Mark post as helpful
  • send pies
  • 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: 165
1
  • Mark post as helpful
  • send pies
  • 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: 437
7
Android Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried debug? Did it goes to the else part?
 
Maha Sakka
Ranch Hand
Posts: 165
1
  • Mark post as helpful
  • send pies
  • 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: 437
7
Android Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any exceptions?
What you want to do with this line?
 
Maha Sakka
Ranch Hand
Posts: 165
1
  • Mark post as helpful
  • send pies
  • 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: 165
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't found a solution so far, could you help me please
 
Randy Tong
Rancher
Posts: 437
7
Android Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wish too.

Is it possible for you to upload your project to git so I can help?
 
It is an experimental device that will make my mind that most powerful force on earth! More powerful than this tiny ad!
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!