How johanadam/android-searchview-recyclerview works
Project Type & Purpose
• This is a beginner‐level Android mobile application demonstrating how to filter/search a list of items in a RecyclerView and how to navigate to a detail screen. There is no external service or database—everything runs in‐memory and uses Android’s Intent system for navigation.
Main Architectural Components
a. UI Layer
• MainActivity
• MainFragment (hosts the SearchView + RecyclerView)
• DetailActivity (displays selected item details)
• Layout XMLs (activity_main.xml, activity_detail.xml, cardview_detail.xml, recyclerview.xml, etc.)
b. Adapter Layer
• RecyclerViewAdapter (binds MemberData items to ViewHolders)
• RecyclerViewViewHolder (holds references to UI widgets for each row)
c. Data Layer
• MemberData.java (Serializable data model)
• In-memory List<MemberData> (holds all items and filtered subset)
d. Build & Config
• Gradle build scripts (app/build.gradle, settings.gradle, gradle wrapper)
• AndroidManifest.xml
• proguard-rules.pro
Relationships & Data Flow
1. User enters text into SearchView in MainFragment
→ MainFragment.onQueryTextChange(newText)
→ calls filter(datas, newText)
→ produces filteredModelList
→ adapter.setItems(filteredModelList); adapter.notifyDataSetChanged()
→ RecyclerView rebinds and redraws only matching items
2. User taps a row in RecyclerView
→ RecyclerViewAdapter’s ViewHolder.onClickListener
→ builds Intent with Bundle.putSerializable("DATA", selected MemberData)
→ context.startActivity(Intent → DetailActivity)
→ DetailActivity.onCreate(): retrieves MemberData and populates UI
Architectural Patterns & Principles
• MVC‐ish separation:
• View = XML layouts + RecyclerView
• Controller = MainFragment, DetailActivity, Adapter
• Model = MemberData + List storage
• Single Responsibility: Adapter only binds and handles click events; Fragment only handles filtering logic and delegates UI updates.
• Loose coupling via Serializable Intent extras.
1. Two large containers: MainActivity (contains MainFragment) and DetailActivity.
2. Inside MainFragment, place SearchView and RecyclerView side by side.
7. Inside DetailActivity, show retrieval of the Serializable “DATA” and population of TextViews.