You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description: I have below structure in my activity_main.xml, incl. SearchBar and SearchView, similar to the documentation. I'm using a ViewPager2 with fragments (one for each tab of the TabLayout, including each a RecyclerView list). Basically, the GUI looks like the Catalog app RecyclerView Demo.
Expected behavior: This is how I understand the Material Design search functionality for my use case:
I click on the SearchBar, the SearchView opens. I enter a search string, the original RecyclerView of the currently selected tab will be searched for the string and the results are shown in the RecyclerView with id search_results_recycler_view (i.e. the one within SearchView).
With setOnEditorActionListener / SearchView.getText, I'm listening for the search string.
Setup:
SearchBar and SearchView are defined in MainActivity
RecyclerViews and adapters are defined in the fragments
Custom adapter for RecyclerView has a getFilter() method implemented
The problem is that I'm not sure on how to...
a) transfer the search string from SearchView to the original RecyclerView list of the currently selected tab and then...
b) transfer the filtered list back to the RecyclerView with id search_results_recycler_view within SearchView.
Shall I use a ViewModel for each transfer part? Easy for a) where I can use String, but for b) it tricky as ViewModel doesn't allow an ArrayList<CustomAdapter>?
The Catalog RecyclerView Demo also doesn't show how to do that as all search results are hard-coded and have no association with the original text, so entering a search string has no effect.
Can you please share some insights (e.g. in the documentation) on how to implement this (best practice) or would you be able to amend the Catalog demo accordingly?
Source code: See above XML code.
Android API version: Tested on Android API 30-35
Material Library version: 1.13.0-alpha07
Device: Pixel 8 emulators, Nokia 7.2
The text was updated successfully, but these errors were encountered:
Description: I have below structure in my
activity_main.xml
, incl.SearchBar
andSearchView
, similar to the documentation. I'm using aViewPager2
with fragments (one for each tab of theTabLayout
, including each aRecyclerView
list). Basically, the GUI looks like the Catalog app RecyclerView Demo.Expected behavior: This is how I understand the Material Design search functionality for my use case:
SearchBar
, theSearchView
opens. I enter a search string, the originalRecyclerView
of the currently selected tab will be searched for the string and the results are shown in theRecyclerView
with idsearch_results_recycler_view
(i.e. the one withinSearchView
).setOnEditorActionListener
/SearchView.getText
, I'm listening for the search string.Setup:
SearchBar
andSearchView
are defined inMainActivity
RecyclerView
s andadapter
s are defined in thefragment
sadapter
forRecyclerView
has a getFilter() method implementedThe problem is that I'm not sure on how to...
a) transfer the search string from
SearchView
to the originalRecyclerView
list of the currently selected tab and then...b) transfer the filtered list back to the
RecyclerView
with idsearch_results_recycler_view
withinSearchView
.Shall I use a
ViewModel
for each transfer part? Easy for a) where I can useString
, but for b) it tricky asViewModel
doesn't allow anArrayList<CustomAdapter>
?The Catalog RecyclerView Demo also doesn't show how to do that as all search results are hard-coded and have no association with the original text, so entering a search string has no effect.
Can you please share some insights (e.g. in the documentation) on how to implement this (best practice) or would you be able to amend the Catalog demo accordingly?
Source code: See above XML code.
Android API version: Tested on Android API 30-35
Material Library version: 1.13.0-alpha07
Device: Pixel 8 emulators, Nokia 7.2
The text was updated successfully, but these errors were encountered: